If "id" is unique, you can change the first sql from: $result = mysql_query("SELECT *, DATE_FORMAT(EventStartDate, '%W %M %D %Y') AS FormattedEventStartDate, DATE_FORMAT(EventEndDate, '%W %M %D %Y') AS FormattedEventEndDate, TIME_FORMAT(EventStartTime, '%r') AS FormattedEventStartTime, TIME_FORMAT(EventEndTime, '%r') AS FormattedEventEndTime FROM comcal WHERE id=$id and EventMonth='".$month."' and EventYear='".$year."'",$db);
to: $result = mysql_query("SELECT *, DATE_FORMAT(EventStartDate, '%W %M %D %Y') AS FormattedEventStartDate, DATE_FORMAT(EventEndDate, '%W %M %D %Y') AS FormattedEventEndDate, TIME_FORMAT(EventStartTime, '%r') AS FormattedEventStartTime, TIME_FORMAT(EventEndTime, '%r') AS FormattedEventEndTime FROM comcal WHERE id=$id",$db); in other words: remove the "month" and "year" from the where clause Martin -----Original Message----- From: Tim Thorburn [mailto:[EMAIL PROTECTED]] Sent: Monday, November 26, 2001 3:58 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Pulling information out of a MySQL database Hi again, Ok, I've heard some suggestions to my problem ... but I'm not entirely certain how to incorporate them, perhaps taking a look at the code would be helpful. Again, the problem I'm having is as follows. I have a simple form in which the user selects a month and year from two drop down menu's - based on their choice, the following PHP script searches a MySQL database and displays a basic listing (event name and date) for the selected month. Then the user has the option to click an event name and receive a more detailed listing of the event - this is the portion that isn't working. It seems that the script is forgetting the values entered by the user - I have come to this conclusion as when I replaced ".$month." and ".$year." with an actual month and year ie. 'November' and '2001' respectively, the detailed display works perfectly. How can I get both the basic and detailed event listings working at the same time? Thanks -Tim <? $db = mysql_connect("localhost", "login", "password"); mysql_select_db("edoinfo",$db); if ($id) { // query for extented information $result = mysql_query("SELECT *, DATE_FORMAT(EventStartDate, '%W %M %D %Y') AS FormattedEventStartDate, DATE_FORMAT(EventEndDate, '%W %M %D %Y') AS FormattedEventEndDate, TIME_FORMAT(EventStartTime, '%r') AS FormattedEventStartTime, TIME_FORMAT(EventEndTime, '%r') AS FormattedEventEndTime FROM comcal WHERE id=$id and EventMonth='".$month."' and EventYear='".$year."'",$db); $myrow = mysql_fetch_array($result); //display extended information echo "<table width='65%' border='0' cellspacing='2' cellpadding='2'>"; echo "<tr>"; echo "<td valign='top' align='left'><b>Event: </b></td>"; echo "<td valign='top' align='left'>"; echo ($myrow["EventName"]); echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td valign='top' align='left'><b>Location: </b></td>"; echo "<td valign='top' align='left'>".($myrow["EventLocation"])."</td>"; echo "</tr>"; echo "<tr>"; echo "<td valign='top' align='left'><b>City: </b></td>"; echo "<td valign='top' align='left'>".($myrow["EventCity"]).", ".($myrow["EventState"])."</td>"; echo "</tr>"; echo "<tr>"; echo "<td valign='top' align='left'><b>Time: </b></td>"; echo "<td valign='top' align='left'>".($myrow["FormattedEventStartTime"])."</td>"; echo "</tr>"; echo "<tr>"; echo "<td valign='top' align='left'><b>Date: </b></td>"; echo "<td valign='top' align='left'>".($myrow["FormattedEventStartDate"])."</td>"; echo "</tr>"; echo "<tr>"; echo "<td valign='top' align='left'><b>Contact Person(s): </b></td>"; echo "<td valign='top' align='left'>".($myrow["EventC1FN"])." ".($myrow["EventC1LN"])."<br>".($myrow["EventC2FN"])." ".($myrow["EventC2LN"])."</td>"; echo "</tr>"; echo "<tr>"; echo "<td valign='top' align='left'><b>Phone: </b></td>"; echo "<td valign='top' align='left'>".($myrow["EventC1ACPhone"]).".".($myrow["EventC1ExcPhone"]).". ".($myrow["EventC1ExtPhone"])." "; echo "<br>".($myrow["EventC2ACPhone"]).".".($myrow["EventC2ExcPhone"]).".".($myro w["EventC2ExtPhone"])." "; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td valign='top' align='left'><b>Fax: </b></td>"; echo "<td valign='top' align='left'>".($myrow["EventACFax"]).".".($myrow["EventExcFax"]).".".($myro w["EventExtFax"])."</td>"; echo "</tr>"; echo "<tr>"; echo "<td valign='top' align='left'><b>Cell: </b></td>"; echo "<td valign='top' align='left'>".($myrow["EventACCell"]).".".($myrow["EventExcCell"]).".".($my row["EventExtCell"])."</td>"; echo "</tr>"; echo "<tr>"; echo "<td valign='top' align='left'><b>Email: </b></td>"; echo "<td valign='top' align='left'><a href='mailto:".($myrow["EventEmail"])."'>".($myrow["EventEmail"])."</a></td> "; echo "</tr>"; echo "<tr>"; echo "<td valign='top' align='left'><b>Web: </b></td>"; echo "<td valign='top' align='left'><a href='".($myrow["EventWeb"])."'>".($myrow["EventWeb"])."</a></td>"; echo "</tr>"; echo "<tr>"; echo "<td valign='top' align='left'><b>Description: </b></td>"; echo "<td valign='top' align='left'>".($myrow["EventDescription"])."</td>"; echo "</tr>"; echo "<tr>"; echo "<td valign='top' align='left'><b>Cost: </b></td>"; echo "<td valign='top' align='left'>".($myrow["EventCost"])."</td>"; echo "</tr>"; echo "<tr>"; echo "<td valign='top' align='left'><b></b></td>"; echo "<td valign='top' align='left'> </td>"; echo "</tr>"; echo "<tr>"; echo "<td valign='top' align='left'><b></b></td>"; echo "<td valign='top' align='left'> </td>"; echo "</tr>"; echo "</table>"; } else { //display basic information from user input form $result = mysql_query("SELECT *, DATE_FORMAT(EventStartDate, '%W %M %D %Y') AS FormattedEventStartDate, TIME_FORMAT(EventStartTime, '%r') AS FormattedEventStartTime FROM comcal WHERE EventMonth='".$month."' and EventYear='".$year."' ORDER BY EventStartDate",$db); if ($myrow = mysql_fetch_array($result)) { echo "<table width=65% border=0 cellspacing=2 cellpadding=2>"; do { echo "<tr>"; echo "<td valign='top' align='left'>"; echo "<a href="; echo "$PHP_SELF?id="; echo ($myrow["id"]); echo ">"; echo ($myrow["EventName"]); echo "</a>"; echo "</td>"; echo "<td valign='top' align='left'>"; echo "<font size='1'>"; echo ($myrow["FormattedEventStartDate"]); echo "</font>"; echo "</td>"; echo "</tr>"; } while ($myrow = mysql_fetch_array($result)); echo "</table>"; } else { // no records to display echo "Sorry, there are no events scheduled for this month"; } } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]