Forums

PHP

This topic is locked

propogating select box

Posted 30 Nov 2006 20:35:31
1
has voted
30 Nov 2006 20:35:31 bill triplett posted:
This code is working fine for propogating the "select" box with all of the choices from "Category_Listing".

I would like to be able to fill the select box with Customer whose category is "places to eat" in the "Category_Listing" column.

This would be on a seperate page.

Currently working at host557.ipowerweb.com/~idyllwil/test_back_members.php

Here is the current code.

<?
// Connect database
mysql_connect("localhost","idyllwil_rdub","bubba";
mysql_select_db("idyllwil_members";

$select = "--select--";

// If submitted, check the value of "select". If its not blank value, get the value and put it into $select.
if(isset($select)&&$select!=""{
if(!empty($_GET['select'])){ $select = $_GET['select']; }
}
?>
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
.style1 {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 11px;
}
-->
</style>
</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 distinct Category_Listing from member_list order by id asc";

// Show records by while loop.
while($row_list=mysql_fetch_assoc($list)){
?>
<option value="<? echo $row_list['Category_Listing']; ?>"
<? 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 Category_Listing='$select'";
while($row=mysql_fetch_assoc($result)) {




?>
</p>
<table width="250" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><strong>
<?

//if ($row != ""{
//echo $row;
//}

echo $row['Customer']; ?>
</strong></td>
</tr>
<tr>
<td><? echo $row['Description']; ?></td>
</tr>
<tr>
<td><? echo $row['Phone']; ?></td>
</tr>
<tr>
<td><? echo $row['Fax']; ?></td>
</tr>
<tr>
<td><? echo $row['Email']; ?></td>
</tr>
<tr>
<td><? echo $row['Web_Link']; ?></td>
</tr>
</table>
<p><br>



<?
// End While statement
}
// End if statement.
}


// Close database connection.
mysql_close();
?>
</p>
<p><br>
</p>
</body>
</html>


Edited by - rdub on 30 Nov 2006 20:39:37

Replies

Replied 01 Dec 2006 13:33:09
01 Dec 2006 13:33:09 Roddy Dairion replied:
Do you mean you want another select box which will list all the categories selected from the 1st box?????

Reply to this topic