Re: How can I display data in web after mysql_query() ??

From: Date: Sun, 03 Dec 2000 04:14:56 +0000
Subject: Re: How can I display data in web after mysql_query() ??
Groups: php.general 
Request: Send a blank email to php-general+get-28405@lists.php.net to get a copy of this message
I recommend that before you try to generate HTML to display your results, you first create a static web page -- no PHP, no MySQL, just HTML -- which displays the page the way you want it to look. When thinking about the layout, be sure to take into account what will happen if you get very long results from your query, or very short values or even no values. Once you have this the way you like it, insert the PHP code that performs the query at the top of the page. Add the PHP code to display column values instead of whatever static values you used when laying out the static HTML. Add some PHP code to loop through the query result set. Voila! You're there. HTH. At 12:18 PM 12/3/2000 +0800, crazyman wrote: >Hello, Iam new bie of PHP. I have write a little php that can connect mysql >server, write data in table, >(beast frist step ! :P), but i dunno how to display the data on the web >after query.. here is my code. > ><? >mysql_connect("localhost", "root", "abc") or die("Unable to >connect DataBase >Server"); > >mysql_select_db("email_list") or die("Unable to connect the database"); > >$sql="select * from list where location='$choice' order by ename ASC"; > >$result= mysql_query($sql) or die("Unable to query result"); > >echo "<Table broder=\"1\">"; > >echo "<tr><TH>English Name</TH><TH>E-mail</TH>"; > >echo "<TH>Chinese >Name</TH><TH>Location</th><TH>UserID</TH></tr>"; > >while ($row =mysql_fetch_arrary($result)) { > >$cname =$row["cname"]; > >$email =$row["email"]; > >$ename =$row["ename"]; > >$location=$row["location"]; > >$userid=$row["userid"]; > >echo >"<tr><TD>$cname</TD><TD>$email/TD><TD>$ename</TD>"; > >echo "<TD>$location</TD><TD>$userid</TD>"; > >} > >and i got earr about this..... > > >Henry Chan from Hong Kong ^_^ >echo "</table>"; > >mysql_free_result($result); > >?> > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >For additional commands, e-mail: php-general-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net > > ...................................................................... Les Neste Cellphone 678-778-0382 Web http://www.lesneste.com

« previous php.general (#28405) next »