Forum Moderators: coopster
i have a list of agents that i just want a simple drop down list to show the records they entered....
right now i just have the entire table showing all records in a html table format...but i want a drop down list so that if they only want to see the ones they entered, they can just select their name and poof...only theirs are shown...
It’s all done in one page – mypage.php – form to select the variety above, table output of form below.
//THIS CHECKS IF YOU’VE ALREADY SELECTED A VARIETY
/* DEFINE VARIETY */
if(!isset($_GET['Variety'])){
$Var ='%';
}
else
{
if($_GET['Variety'] == "ALL"){
$Var = '%';
} else {
$Var = $_GET['Variety'];
}
}
//THIS PUTS A FORM WITH A DROP DOWN BOX TO SELECT THE VARIETY, AND SHOW THE VARIETY IF ALREADY SELECTED
echo "<form action=\"mypage.php\" method=\"GET\">
<table border=0 cellpadding=5 align=center><tr><td><b>Variety</b><br>";
$res=mysql_query("select * from Variety ORDER BY Variety");
if(mysql_num_rows($res)==0){
echo "there is no data in table..";
} else {
echo "<select name=\"Variety\" id=\"Variety\"><option value=\"ALL\">ALL</option>";
for($i=0;$i<mysql_num_rows($res);$i++) {
$row=mysql_fetch_assoc($res);
echo"<option value=$row[VarietyID]";
if($Var==$row[VarietyID])
echo " selected";
echo ">$row[Variety]</option>";
}
echo "</select>";
}
echo "</td><td align=\"center\"><input type=\"submit\" value=\"Search Now\" />
</td></tr></table></form><br>";
//THIS TAKES THE VARIETY YOU’VE SELECTED, QUERIES THE DATABASE FOR ALL THE RQUIRED INFO AND OUTPUTS YOUR RESULTS
$query = "SELECT * FROM Variety WHERE VarietyID LIKE '$Var' ";
$result = mysql_query($query) or die("Error: " . mysql_error());
if(mysql_num_rows($result) == 0){
echo("No Varieties match your currently selected criteria. Please try another selection!");
} ELSE {
// Your table to display the output of your query goes in here
}
here is the page code...
<table width="300" border="0" cellpadding="3" cellspacing="3" bgcolor="#C3C67C">
<form action="{page_link_28}" method="post">
<tr>
<td width="79%">Enter Record Number to Modify:</td>
<td width="21%"><INPUT TYPE="text" NAME="rec_id" SIZE="9" MAXLENGTH="5"></td>
</tr>
<tr>
<td> </td>
<td><INPUT TYPE="submit" NAME="go" VALUE="Modify"></td>
</tr>
</form>
</table>
<!--<?php
//connect to database here
$q="SELECT * FROM Registration_Data ORDER BY nhm_associate ASC";
$result = mysql_query( $q, $dbh )
or die(" - Failed More Information:<br><pre>$q</pre><br>Error: " . mysql_error());
$num_rows = mysql_num_rows($result);
if ($myrow = mysql_fetch_array($result)) {
echo "<table width='2010' cellpadding='2' cellspacing='2'><tr><td><table width='2000' border='1' style='border-collapse: collapse' align='center' cellpadding='2' cellspacing='2'>";
echo "<tr bgcolor='#E9EAD0'><td><b>Record ID</b></td><td><b>Lead Date</b></td><td><b>NHM Assoc.</b></td><td><b>First</b></td><td><b>Last</b></td><td><b>H PH#</b></td><td><b>C PH#</b></td><td><b>Email</b></td><td width='700'><b>Remarks</b></td></tr>";
do {
printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td width='700'>%s</td></tr>", $myrow["rec_id"],$myrow["lead_date"],$myrow["nhm_associate"], $myrow["fname"], $myrow["lname"], $myrow["home_phone"], $myrow["cell_phone"], $myrow["email"], $myrow["remarks"]);
} while ($myrow = mysql_fetch_array($result));
echo "</table></td></tr></table>";
} else {
echo "$ref: That record appears to be unavailable";
}
mysql_free_result($result);
mysql_close($db);
?>-->