mattennant Posted August 16, 2006 Share Posted August 16, 2006 I'm trying to prduce an events calendar similaar to the one here[url=http://fat-cat.co.uk/fatcat/events.php]http://fat-cat.co.uk/fatcat/events.php[/url]I think i need to run a query to produce a unique month from my table, and within that loop run a second query for the days. I've successfully got the first loop running, it's the second i'm struggling with. is there a simple answer to this problem.here's the code[code]<?php$query= "SELECT distinct DATE_FORMAT(date,'%M %Y') AS dr FROM hoarse_events ORDER BY date ASC";$result = mysql_query ($query);$query2= "SELECT DATE_FORMAT(date,'%M %d %Y') AS dr FROM hoarse_events ORDER BY date ASC";$result2 = mysql_query ($query2); if($result){echo'<table align="left" cellspacing="" cellpadding""> ';//fetchand print all resultswhile ($row = mysql_fetch_array($result, MYSQL_NUM)){echo"<tr><td align=\"left\">$row[0]</td><td align=\"left\">$row[2]</td></tr>\n";}echo '</table>';mysql_free_result ($result);//free up resources}else{//if it did not run okecho'<p> something is wrong.</p><p>' . mysql_error().'</P>';}?>[/code]I've tried sticking the second loop within the first, but i'm getting nothing but errors, any help much appreciated Link to comment https://forums.phpfreaks.com/topic/17726-running-a-second-query-in-a-while-loop/ Share on other sites More sharing options...
brown2005 Posted August 16, 2006 Share Posted August 16, 2006 how horrible is the select boxes on that site... they need to be bigger. lol Link to comment https://forums.phpfreaks.com/topic/17726-running-a-second-query-in-a-while-loop/#findComment-75608 Share on other sites More sharing options...
otuatail Posted August 16, 2006 Share Posted August 16, 2006 Running a query within a queery can be slow to say the least. Re-think your plan. Maybee get the user to pick a day first and then on another page list the vents for that/Desmond. Link to comment https://forums.phpfreaks.com/topic/17726-running-a-second-query-in-a-while-loop/#findComment-75617 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.