Dynamic list and producing row on the form page
Posted: Sun Dec 05, 2004 9:22 pm
I have created the following dynamic drop down:
On the page the form is pointing to, test.php3, I am able to call out $event and that event (cell) is returned, but how would I return the whole row instead of just the $event value?
I have an example http://www.fobsgonewild.com/tickets/mainsearch.php
If you go to the link above and you choose an item from the drop down, then click next, that item is output on the following screen using the $event variable. I want the whole row to print also.
I tried doing something like this on "test.php3":
and I am getting an error on the following line from the above code:
Any input would be appreciated, or any tutorials to point me in the right direction.
thanks
Code: Select all
<form method="post" action="test.php3">
<?php
$db = mysql_connect("x", "y", "z");
mysql_select_db("db114469701",$db);
$sql = "SELECT event FROM tickets ORDER BY event ASC";
$result = mysql_query($sql) OR die(mysql_error());
echo '<select name="event">';
while ( $row = mysql_fetch_object($result) )
{
echo '<option>' .$row->event. '</option>';
}
echo '</select>';
?>
<input type=submit value="next"></td></form>I have an example http://www.fobsgonewild.com/tickets/mainsearch.php
If you go to the link above and you choose an item from the drop down, then click next, that item is output on the following screen using the $event variable. I want the whole row to print also.
I tried doing something like this on "test.php3":
Code: Select all
<?php
<?
echo "$event<br>";
if ($event)
{
mysql_connect('x','y','z') or die ("Problem connecting to Database");
mysql_select_db(d) or die( "Unable to select database");
$query = "select * from tickets WHERE event like '%$event%'";
$result = mysql_query($query) or die("Unable to select Database");
if (!$result) die("select * from tickets WHERE event like $event failed: ".mysql_error());
if ($result)
{
echo "<font face='Arial, Helvetica, sans-serif' color='#000000'>Your search for $event produced the following result:</font><br><br>";
echo "<table width=90% align=center border=1><tr>
<td align=center bgcolor=#009999><font face='Arial, Helvetica, sans-serif' color='#FFFFFF'><b>Event</b></font></td>
<td align=center bgcolor=#009999><font face='Arial, Helvetica, sans-serif' color='#FFFFFF'><b>Venue</b></font></td>
<td align=center bgcolor=#009999><font face='Arial, Helvetica, sans-serif' color='#FFFFFF'><b>Seat</b></font></td>
<td align=center bgcolor=#009999><font face='Arial, Helvetica, sans-serif' color='#FFFFFF'><b>Cost</b></font></td>
<td align=center bgcolor=#009999><font face='Arial, Helvetica, sans-serif' color='#FFFFFF'><b>Quantity*</b></font></td>
</tr>";
while ($row = mysql_fetch_array($event,MYSQL_NUM)) { // Begin while
echo "<tr><td align="left">$row[1]</td><td align="left">$row[2]</td><td align="left">$row[3]</td><td align="left">$row[4]</td><td align="left">$row[5]</td></tr>\n";
} // end while
echo "</table>";
} else { echo "problems...."; }
} else {
echo "Your search was empty. <br> Click back on your browser and type an event to search";
}
include ('links.x');
?>
?>Code: Select all
while ($row = mysql_fetch_array($event,MYSQL_NUM))thanks