Jump to content

Recommended Posts

Hi

 

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:

 

<?php
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/xampp/testingserver/event...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.

 

<?php
$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

Link to comment
https://forums.phpfreaks.com/topic/2024-help-needed-picking-up-bits-of-dates/
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.