loops again
Posted: Sat Jan 20, 2007 4:46 am
hi, i'm trying to build a table dyanmically by adding stuff from a database but the code isn't returning anything. Please can someoone take a look to see where i'm going wrong. garry
Code: Select all
/*************** query db for pub info for pubs in list ****************************/
db_connect();
$sql = mysql_query("SELECT Pubs.pubID, Pubs.pubName, Pubs.pubPostcode from Pubs
WHERE $sql_str ")
or die ('query2 invalid on table_data.php: ' . mysql_error() );
$row = mysql_fetch_assoc($sql);
$numrows = mysql_num_rows($sql);
/******************************** build html table rows for each pub in list***********************************/
$i=0;
$table_rows = array();
while($row)
{
$i++;
extract($row);
$cellA = "<a href='#' img class='list-btn'><img src='images/up_arr.jpg' width='13' height='12'>
<a href='#' img class='list-btn' ><img src='images/down_arr.jpg' width='13' height='12'> </a></td>";
$cellB = $pubName . ', ' . $pubPostcode;
$cellC = "<a href='#'img class='list-btn' ><img src='images/cross.jpg' width='13' height='12'></a>";
$table_rows[] =
"<tr id='tr1' class='tr1'>
<td class='td1'>
$cellA
</td>
<td class='td1'>
$cellB
</td>
<td class='td1'>
$cellC
</td>
</tr>";
}
/*************** create tbody tags and add array of rows **************************************/
$table_rows = implode(" ", $table_rows );
$table = '<tbody>'
. $table_rows .
'</tbody>';