MySQL Forums
Forum List  »  Newbie

printing fetched values
Posted by: David Schwartz
Date: March 02, 2009 12:52AM

So, I'm trying to create a html table based on data drawn from a database. I want to format each table cell and so intend to specify each separately.

Here's the code snippet:
// Until there are no rows in the result set, fetch a row into
// the $row array and ...
while ($row = @ mysql_fetch_row($result))
// ... start a TABLE row ...
print "\n<tr>";

// ... and print out each of the attributes in that row as a
// separate TD (Table Data).
print "\n\t<td width='20'> {$row["part_id"]} </td>";
print "\n\t<td width='40'> {$row["household_rep"]} </td>";
print "\n\t<td width='50'> {$row["street_address"]} </td>";
print "\n\t<td width='20'> {$row["city"]} </td>";
print "\n\t<td width='10'> {$row["state"]} </td>";
print "\n\t<td width='20'> {$row["zipcode"]} </td>";
print "\n\t<td width='30'> {$row["phone"]} </td>";
print "\n\t<td width='30'> {$row["email"]} </td>";

// Finish the row
print "\n</tr>";

// Then, finish the table
print "\n</table>\n";

While this seems to be what's suggested in the text I'm using, I get the following errors:

Notice: Undefined index: part_id in C:\wamp\www\report.php on line 29
Notice: Undefined index: household_rep in C:\wamp\www\report.php on line 30
Notice: Undefined index: street_address in C:\wamp\www\report.php on line 31
Notice: Undefined index: city in C:\wamp\www\report.php on line 32
Notice: Undefined index: state in C:\wamp\www\report.php on line 33

These are the lines where the specific attribute values are printed.

Any ideas what the problem might be?

Options: ReplyQuote

Written By
printing fetched values
March 02, 2009 12:52AM
March 02, 2009 03:25AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.