display mor than one result.

From: Date: Fri, 16 Feb 2001 17:18:16 +0000
Subject: display mor than one result.
Groups: php.general 
Request: Send a blank email to php-general+get-40178@lists.php.net to get a copy of this message
Can Anybody help with this code it is currently only listing the very last entry record in my db however i want it to list however many the query finds can anybody see what I am doing wrong. thanks Matt. <?php //connect $connection = mysql_connect("localhost","*******","*******") or die ("Couldn't connect to server."); //select db $db = mysql_select_db ("business", $connection) or die ("Couldn't select database."); //create sql statement $sql = "select Business_Name,Address_Line_1,Address_Line_2,Address_Line_3,Address_Line_4,Ad dress_Line_5,Address_Line_6,Contact_Person,Telephone,Fax,Mobile,E_Mail,Link, URL,Trading_Details from Main"; //execute sql query and get results $sql_result = mysql_query($sql) or die ("Couldn't execute query."); ?> <HEAD> <TITLE> Business Search </TITLE> </HEAD> <BODY LEFTMARGIN="0" TOPMARGIN="0" ALINK="#b567fb" LINK="#000000" VLINK="#c0c0c0"> <?php /*results variables for data to be displayed*/ while ($row = mysql_fetch_array($sql_result)) { $businessname = $row["Business_Name"]; $addressline1 = $row["Address_Line_1"]; $addressline2 = $row["Address_Line_2"]; $addressline3 = $row["Address_Line_3"]; $addressline4 = $row["Address_Line_4"]; $addressline5 = $row["Address_Line_5"]; $addressline6 = $row["Address_Line_6"]; $contactperson = $row["Contact_Person"]; $telephone = $row["Telephone"]; $fax = $row["Fax"]; $mobile = $row["Mobile"]; $email = $row["E_Mail"]; $link = $row["Link"]; $url = $row["URL"]; $tradingdetails = $row["Trading_Details"]; } //deal with website if ($url != '') { $me="<A HREF=\"http://".$url."\" TARGET='_blank'><IMG BORDER=\"0\" SRC=\"website.gif\"></A>"; } else { $me=" "; } // end of deal website ?> <CENTER> <TABLE BACKGROUND="../../images/misc/ryw_background_top.gif" BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%"> <TR> <TD ALIGN="center"> <FONT COLOR="#ffffff" FACE="verdana, arial, century gothic" SIZE="1"> </FONT> </TD> </TR> </TABLE> <BR> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="500"> <TR> <TD ALIGN="center"> <FONT FACE="verdana" SIZE="1" COLOR="#000000"> <FONT SIZE="2"> <B> Business Search Results </B> </FONT> <BR> <B> You Searched for <FONT COLOR="#ff9933"> Consultancy </FONT> in <FONT COLOR="#ff9933"> Bassingbourn </FONT>, here are the results... </B> </FONT> </TD> </TR> </TABLE> <BR> <!--start of search results--> <TABLE BACKGROUND='ryw_background_top.gif' BORDER='0' CELLPADDING='1' CELLSPACING='0' WIDTH='100%'> <TR> <TD ALIGN='center'> <FONT COLOR='#ffffff' FACE='verdana, arial, century gothic' SIZE='2'> <B> <? echo "$businessname" ?> </B> </FONT> </TD> </TR> </TABLE> <BR> <TABLE BORDER='0' CELLPADDING='0' CELLSPACING='0' WIDTH='500'> <TR> <TD ALIGN='center' VALIGN='top'> <FONT COLOR='#000000' FACE='verdana, arial, century gothic' SIZE='1'> <B> <? echo "$tradingdetails" ?> </B> </FONT> </TD> </TR> </TABLE> <BR> <TABLE BORDER='0' CELLPADDING='0' CELLSPACING='0' WIDTH='500'> <TR> <TD ALIGN='center' VALIGN='top' WIDTH='34%'> <FONT COLOR='#000000' FACE='verdana, arial, century gothic' SIZE='1'> <B> Address </B> <BR> <? echo "$addressline1" ?> <BR> <? echo "$addressline2" ?> <BR> <? echo "$addressline3" ?> <BR> <? echo "$addressline4" ?> <BR> <? echo "$addressline5" ?> <BR> <? echo "$addressline6" ?> <BR> </FONT> </TD> <TD ALIGN='center' VALIGN='top' WIDTH='33%'> <FONT COLOR='#000000' FACE='verdana, arial, century gothic' SIZE='1'> <B> Contact Details </B> <BR> <? echo "$contactperson" ?> <BR> TEL: <? echo "$telephone" ?> <BR> MOB: <? echo "$mobile" ?> <BR> FAX: <? echo "$fax" ?> <BR> E-mail: <A HREF="mailto:<? echo "$email" ?>"><? echo "$email" ?></A> <BR> </FONT> </TD> <TD ALIGN='center' VALIGN='top' WIDTH='33%'> <FONT COLOR='#000000' FACE='verdana, arial, century gothic' SIZE='1'> <B> Links </B> </FONT> <?echo "$me" ?> </TD> </TR> </TABLE> <BR> <!--end of search results--> <BR> <TABLE BACKGROUND="ryw_background_top.gif" BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%"> </TABLE> <TABLE BORDER="0" CELLPADDIN="0" CELLSPACING="0" WIDTH="500"> <TR> <TD ALIGN="center"> <FONT FACE="verdana, arial, century gothic" COLOR="#000000" SIZE="1"> This service was brought to you by </FONT> <A HREF="http://www.roundyourway.com" TARGET="_blank"> <FONT FACE="verdana, arial, century gothic" COLOR="#000000" SIZE="1"> Round Your Way </FONT> </A> </TD> </TR> </TABLE> <BR> </CENTER> <?PHP //close connection mysql_free_result ($sql_result); mysql_close ($connection); ?> </BODY> </HTML>

« previous php.general (#40178) next »