Jump to content


Help needed picking up bits of dates

  • Please log in to reply
No replies to this topic

#1 bluedogatdingdong

  • Members
  • PipPip
  • Member
  • 10 posts
  • LocationPenzance, Cornwall

Posted 26 October 2004 - 02:31 PM


I'm a newbie, I keep dipping in and out of PHP/MYSQL and am using Dreamweaver to generate code.

I am trying to set up a diary of events.
I can select all the distinct months and pass to a query page, like so:

mysql_select_db($database_cwt, $cwt);
$query_Recordset5 = "SELECT distinct monthname(Date), DATE_FORMAT(Date, '%M') as month FROM events ORDER BY events.`Date`";
$Recordset5 = mysql_query($query_Recordset5, $cwt) or die(mysql_error());
$row_Recordset5 = mysql_fetch_assoc($Recordset5);
$totalRows_Recordset5 = mysql_num_rows($Recordset5);
This works fine and generates the correct url, http://localhost/xam...hp?date=January

But I can't seem to retrieve it through the query page, I've tried alsorts, most of which is generated by Dreamweaver.

$colname_Recordset1 = "1";
if (isset($HTTP_GET_VARS['date'])) {
  $colname_Recordset1 = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['date'] : addslashes($HTTP_GET_VARS['date']);
mysql_select_db($database_cwt, $cwt);
$query_Recordset1 = sprintf("SELECT * FROM events WHERE (DATE_FORMAT('date', '%M') = '%s'", $colname_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $cwt) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
I seem to be getting worse instead of better.

Is my syntax just muddled or have I got it completely wrong?

Any suggestions welcome

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users