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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.