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
https://forums.phpfreaks.com/topic/113801-selecting-dates/
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
https://forums.phpfreaks.com/topic/113801-selecting-dates/#findComment-584787
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
https://forums.phpfreaks.com/topic/113801-selecting-dates/#findComment-584792
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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