Jump to content

displaying query results


sonnyboy

Recommended Posts

Hello folk I have a football league table and I'm trying to number my rows in the column named "Pos" but so far I not getting any success, someone please bail me out find below my script, this script displays my results fine but without my Positions (Pos);

 

<?php

 

function printTable($result)

{

$i=0;

//get the first row in the table:

if(!$row = mysql_fetch_assoc($result))

{

return false;

}

 

//set up the table:

print("<table><tr>");

print ("<th>Pos</th>");

 

//print the column names as table headers:

foreach($row as $key=>$value)

{

print("<th>$key</th>");

}

print("</tr>");

 

//loop through the table, printing

//the field values in table cells:

do

{

$i++;

print("<tr>");

print ("<td>$i</td>");

foreach($row as $key=>$value)

{

print("<td>$value</td>");

}

print("</tr>");

}

while ($row = mysql_fetch_assoc($result));

 

//close out the table:

print("</tr></table>");

return true;

}

?>

Link to comment
https://forums.phpfreaks.com/topic/45644-displaying-query-results/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.