Forum Moderators: coopster

Message Too Old, No Replies

help me correct this php mysql

         

legendcrest

12:33 pm on Jul 29, 2008 (gmt 0)

10+ Year Member



Pls can u help me correct this php.below is the code
$data = mysql_query("SELECT * FROM parishaddress WHERE name ='$parish'") or die(mysql_error());
Print "<table border cellpadding=3>";
Print "<tr><td>Name</td><td>Address</td><td>He...
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
Print "<td>Name</td>".$info['Name'] . "</td> ";
Print "<td>Address</td>".$info['Address'] . " </td>";
Print "<td>Head</td>".$info['Head'] . "</td> ";
Print "<td>Phone No</td>".$info['Contact'] . " </td>";
Print "</tr>";
}
Print "</table>";
?>

StoutFiles

12:45 pm on Jul 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can use the word print instead of echo? If that works I never knew that...

Print "<tr><td>Name</td><td>Address</td><td>He...

the <td> at the end is unneeded. Also, you need the "; at the end.

[edited by: StoutFiles at 12:45 pm (utc) on July 29, 2008]

cameraman

2:12 pm on Jul 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, legendcrest!
As long as you're defining $parish somewhere the php looks ok, I think your only problem is the extra </td> in the middles of the lines:
Print "<td>Name</td>".$info['Name'] . "</td> ";

should be
Print "<td>Name".$info['Name'] . "</td> ";

But since you're doing a header row, I'm not understanding why you're repeating the titles - perhaps do:
Print "<td>".$info['Name'] . "</td> ";
instead.

legendcrest

5:18 pm on Jul 29, 2008 (gmt 0)

10+ Year Member



Thanks it works