Jump to content

running a second query in a while loop


mattennant

Recommended Posts

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 results

while ($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 ok
echo'<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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.