Jump to content

Selecting Dates


PHP Nubsauce

Recommended Posts

Hey Guys, What I'm trying to do is only select scheduled events from the calandar for a certain month.

 

<?php $links2 = @mysql_query("SELECT * FROM ".$mysql_pretext."_calendar ");

 

How can I select only June?

 

This is the data convert I use at the top of the page.

 

}  function dateconvert($date,$func) { 
        if ($func == 1){ //insert conversion 
            list($day, $month, $year) = split('[/.-]', $date);  
            $date = "$year-$month-$day";  
            return $date; 
        } 
        if ($func == 2){ //output conversion 
            list($year, $month, $day) = split('[-.]', $date);  
            $date = "$month/$day/$year";  
            return $date; 
        } }

 

any help would be much appriciated

 

 

nubsauce

 

 

Link to comment
Share on other sites

first you are doing sutff very poorly

 

DO NOT SUPPRESS ERRORS WHEN ASKING QUESTIONS!!!!

 

You query should be in the nature of

<?php
$q = "select * from `table`";
$r = mysql_query($q) or die(mysql_error()."<br /><br />".$q);
?>

 

Next we need to see some structure behind your table.

Link to comment
Share on other sites

I don't understand how I am doing things poorly, everything works mint. I see how your query would work, but whats the problem with mine.. ???

 

Anyways, here is my whole query

 

<?php $links2 = @mysql_query("SELECT * FROM ".$mysql_pretext."_calendar ");
if (!$links2) {
echo("Error retrieving calendar from the database!<br>Error: " . mysql_error());
exit();
}
while ($link = mysql_fetch_array($links2)) {
$id = $link["ID"];
$title1 = $link["title"];
$date1 = $link["date"];
$date = dateconvert($date1, 2);
$dateday = date('d',  strtotime($date1));
$description = $link["description"];
$shortdescription = $link["short_description"];

 

once again, here is my data input for Date

 

}  function dateconvert($date,$func) { 
        if ($func == 1){ //insert conversion 
            list($day, $month, $year) = split('[/.-]', $date);  
            $date = "$year-$month-$day";  
            return $date; 
        } 
        if ($func == 2){ //output conversion 
            list($year, $month, $day) = split('[-.]', $date);  
            $date = "$month/$day/$year";  
            return $date; 
        } }

 

Month, Day, and Year are all inserted originally as raw numbers, 1 2 3 4 and so on.

 

???

 

My only issue is it pulls up all scheduled events on the calandar, rather then just the month i want to display.

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.