Code:<html> <head><title> How to Grab your MySQL Data </title></head> <body bgcolor="#f0f0f0"> <? $DBhost = "localhost"; $DBuser = "root"; $DBpass = "psswrod"; $DBName = "contacts"; $table = "contacts"; mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database"); @mysql_select_db("$DBName") or die("Unable to select database $DBName"); $sqlquery = "SELECT * FROM $table"; $result = mysql_query($sqlquery); $number = mysql_numrows($result); $i = 0; if ($number < 1) { print "<CENTER><P>There Were No Results for Your Search</CENTER>"; } else { while ($number > $i) { $name = mysql_result($result,$i,"name"); $office = mysql_result($result,$i,"office"); $mobile = mysql_result($result,$i,"mobile"); print "Name: $name Office: $office Mobile: $mobile<br>"; $i++; } } ?> </BODY></HTML>
how can i get that to display as a table? if i put my html code after the print " it all goes pete tong.
my html:
Code:<table border="1" width="100%" height="30" style="border-style: solid; border-width: 1px"> <tr> <td style="border-style: dotted; border-width: 1px" bgcolor="#3F789A"> <font face="Verdana" size="2" color="#FFFFFF"><b>Name</b></font></td> <td style="border-style: dotted; border-width: 1px" bgcolor="#3F789A"> <font face="Verdana" size="2" color="#FFFFFF"><b>Office </b></font><b> <font face="Verdana" size="2" color="#FFFFFF">Phone</font></b></td> <td style="border-style: dotted; border-width: 1px" bgcolor="#3F789A"> <font face="Verdana" size="2" color="#FFFFFF"><b>Mobile</b></font></td> </tr> <tr> <td style="border-style: dotted; border-width: 1px"><font face="Verdana" size="2"><?php echo($name); ?></td> <td style="border-style: dotted; border-width: 1px"><font face="Verdana" size="2"><?php echo($office); ?></td> <td style="border-style: dotted; border-width: 1px"><font face="Verdana" size="2"><?php echo($mobile); ?></td> </tr> </table>


LinkBack URL
About LinkBacks
Reply With Quote


