PHP/MySQL query help required... :help:

Codes here !

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Mon Feb 17, 2014 8:48 am

PHP/MySQL query help required... :help:

Postby centralexpert » Thu Feb 20, 2014 5:07 am

Hi there,

I'm struggling to get the following php/mysql function to display the correct info and would appreciate some input on where i'm going wrong.

The function displays a list of accounts from one mysql table then displays dates from another table using the field terms_code as a link.

The list of accounts is displayed however the dates from the other table are not.

I've already spent far too long on this and i'm sure it's going to be a simple oversight.

Code: Select all


function show_accounts_with_grouped_terms() {
  $retval = '';
  $retval .= '<p class="sub-title">Customer Accounts with Grouped Terms</p>';
  $retval .= '<div class="column">';   
  $retval .= '<table class="full-blue" cellspacing="0">';
  $retval .= '<thead>';
  $retval .= '<tr>';
  $retval .= '<th>A/C</th>';
  $retval .= '<th>Description</th>';
  $retval .= '<th>Terms Code</th>';
  $retval .= '<th>P1 From</th>';
  $retval .= '<th>P1 To</th>';
  $retval .= '<th>&nbsp;</th>';
  $retval .= '<th>P2 From</th>';
  $retval .= '<th>P2 To</th>';
  $retval .= '<th>&nbsp;</th>';
  $retval .= '<th>Fixed Until</th>';
  $retval .= '<th colspan="2">&nbsp;</th>';
  $retval .= '</tr>';
  $retval .= '</thead>';
  $retval .= '<tbody>';
  $date = date("d/m/Y");
  $sql = mysql_query("SELECT * FROM cf_terms_groups ORDER BY account_name") or die(mysql_error());
  while($row = mysql_fetch_array($sql)) {
    $rs = mysql_query("SELECT * FROM cf_terms_headers WHERE terms_code = '".$row["terms_code"]."'") or die(mysql_error());
    $data = mysql_fetch_assoc($rs) or die(mysql_error());
    $retval .= '<tr>';
    $retval .= '<td align="center">';
    $retval .= '<form target="_blank" action="pages/price-list-print-tg.php" method="post">';
    $retval .= '<input type="hidden" name="account_number" value="'.$row["account_number"].'">';
    $retval .= ''.$row["account_number"].'</td>';
    $retval .= '<td>'.$row["account_name"].'</td>';
    $retval .= '<td>'.$row["terms_code"].'</td>';
    $retval .= '<td align="center">'.$data["p1_from"].'</td>';
    $retval .= '<td align="center">'.$data["p1_to"].'</td>';
    $retval .= '<td align="center"><input type="radio" name="period" value="1"></td>';
    $retval .= '<td align="center">'.$data["p2_from"].'</td>';
    $retval .= '<td align="center">'.$data["p2_to"].'</td>';
    $retval .= '<td align="center"><input type="radio" name="period" value="2"></td>';
    $retval .= '<td align="center">'.$data["fixed_until"].'</td>';
    $retval .= '<td align="center">&nbsp;</select></td>';
    $retval .= '<td align="center"><input type="submit" value=" Print " name=""></form></td>';
    $retval .= '</tr>';
    $retval .= '</tbody>';
    $retval .= '</table>';

  $retval .= '</div>';
  print $retval;   


Return to “mySQL & php coding”

Who is online

Users browsing this forum: Baidu [Spider] and 3 guests