OK, I need help on a script. I seem to be making headway, but the last bit is not coming willingly, and I don't know what else to try.
I have one table in a mysql db that I call "stories" and another that I call "dates". For each date, there can either be 0 stories up to an unlimited amount of stories. The script I'm trying to create lists each date, and then directly underneath lists all the stories that occurred on that date, then continues on to the next date and does the same. Both tables have a 'dateid' field to help identify what stories belong to which date. I've gotten code working to list all the dates, and all the stories under the first date, but for some reason, no stories get returned for any of the following dates. I do have some dummy stories in the database that should be returned for all the dates listed.
I'm not a real experienced php/mysql coder, so if there are flaws in my database design or general approach, I'd appreciate help working that out as well, but more importantly, I'm looking for a workable solution.
The db structure as I have it is at:
http://sonsoftheday.com/php/dates_stories.txt,
and will include the php code below. Any and all help would be appreciated! Thanks!
Here's some code:
<?php require_once('Connections/
mediarevie
w.php'); ?>
<?php
mysql_select_db($database_
mediarevie
w, $mediareview);
$query_datesrecordset = "SELECT * FROM dates";
$datesrecordset = mysql_query($query_datesre
cordset, $mediareview) or die(mysql_error());
$row_datesrecordset = mysql_fetch_assoc($datesre
cordset);
$totalRows_datesrecordset = mysql_num_rows($datesrecor
dset);
mysql_select_db($database_
mediarevie
w, $mediareview);
$query_storiesrecordset = "SELECT * FROM stories";
$storiesrecordset = mysql_query($query_stories
recordset,
$mediareview) or die(mysql_error());
$row_storiesrecordset = mysql_fetch_assoc($stories
recordset)
;
$totalRows_storiesrecordse
t = mysql_num_rows($storiesrec
ordset);
?>
<?php do { ?>
<br />
<?php echo $row_datesrecordset['datei
d']; ?>
<?php echo date("F j, Y", strtotime($row_datesrecord
set['date'
])); ?><br />
<?php do { ?>
<?php if ($row_storiesrecordset['da
teid'] == $row_datesrecordset['datei
d'])
echo $row_storiesrecordset['sto
rytitle'];
?>
<br />
<?php } while ($row_storiesrecordset = mysql_fetch_assoc($stories
recordset)
); ?>
<br />
<br />
<?php } while ($row_datesrecordset = mysql_fetch_assoc($datesre
cordset));
?>
<strong>
<?php
mysql_free_result($stories
recordset)
;
mysql_free_result($datesre
cordset);
?>