rdub 0 Newbie Poster

Seems to search fine but only displays first record of result. Need to display all matching records.


Here is the code

<? 
// Connect database 
mysql_connect("localhost","user","pass"); 
mysql_select_db("members"); 
// If submitted, check the value of "select". If its not blank value, get the value and put it into $select. 
if(isset($select)&&$select!=""){ 
$select=$_GET['select']; 
} 
?> 
<html xmlns="[URL]http://www.w3.org/1999/xhtml[/url] "> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
</head> 
<body> 
<form ID="form1" Category Listing"form1" method="get" action="<? echo $PHP_SELF; ?> "> 
Selections : 
<select name="select"> 
<option value="">--- Select ---</option> 
<? 
// Get records from database (table "member_list"). 
$list=mysql_query("select * from member_list order by id asc"); 
// Show records by while loop. 
while($row_list=mysql_fetch_assoc($list)){ 
?> 
<option value="<? echo $row_list['ID']; ?>" <? if($row_list['ID']==$select){ echo "selected"; } ?>><? echo $row_list['Category Listing']; ?></option> 
<? 
// End while loop. 
} 
?> 
</select> 
<input type="submit" name="Submit" value="Select" /> 
</form> 
<hr> 
<p> 
<? 
// If you have selected from list box. 
if(isset($select)&&$select!=""){ 
// Get records from database (table "member_list"). 
$result=mysql_query("select * from member_list where ID='$select'"); 
while($row=mysql_fetch_assoc($result)) {
 
?> 
Information about <strong><? echo $row['Customer']; ?></strong> company...</p> 
<? 
// End While statement
}
// End if statement. 
} 

// Close database connection. 
mysql_close(); 
?> 
</p> 
</body> 
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.