Jump to content

Making a post calendar


Avalanche

Recommended Posts

Hello.

 

I am making a journal/web blog type of thing, and I\'m going to have a calendar that lists any posts made on whichever days. I have:

 

[php:1:df95bb1102]<?php

 

include \"config.php\";

 

$db = mysql_connect($db_host,$db_user,$db_pass);

mysql_select_db ($db_name) or die (\"Cannot connect to database\");

/* We have now connected, unless you got an error message */

/* Lets display the current titles, so we can select one for editing */

echo \"Please click on a command next to a title to execute<br>the corresponding command on the corresponding entry:<p>\";

$query = \"SELECT id, title FROM news WHERE date=\'2003-04-01\' ORDER BY id DESC\";

$result = mysql_query($query);

/* Here we fetch the result as an array */

while($r=mysql_fetch_array($result))

{

/* This bit sets our data from each row as variables, to make it easier to display */

$id=$r[\"id\"];

$title=$r[\"title\"];

/* Now lets display the titles */

echo \"<table border=\'1\' cellspacing=\'2\' cellpadding=\'2\'><tr>\";

echo \"<td align=\'center\' valign=\'center\' colspan=\'7\'><FONT face=Verdana color=black size=10><b><u>April</u></b></td></tr>\";

echo \"<tr><td width=\'85\' height=\'15\' align=\'center\' valign=\'center\'><FONT face=\'Times New Roman\' color=\'white\' size=\'3\'><u>Sunday</u></font></td>\";

echo \"<td width=\'85\' height=\'15\' align=\'center\' valign=\'center\'><FONT face=\'Times New Roman\' color=\'white\' size=\'3\'><u>Monday</u></font></td>\";

echo \"<td width=\'85\' height=\'15\' align=\'center\' valign=\'center\'><FONT face=\'Times New Roman\' color=\'white\' size=\'3\'><u>Tuesday</u></font></td>\";

echo \"<td width=\'85\' height=\'15\' align=\'center\' valign=\'center\'><FONT face=\'Times New Roman\' color=\'white\' size=\'3\'><u>Wednesday</u></font></td>\";

echo \"<td width=\'85\' height=\'15\' align=\'center\' valign=\'center\'><FONT face=\'Times New Roman\' color=\'white\' size=\'3\'><u>Thursday</u></font></td>\";

echo \"<td width=\'85\' height=\'15\' align=\'center\' valign=\'center\'><FONT face=\'Times New Roman\' color=\'white\' size=\'3\'><u>Friday</u></font></td>\";

echo \"<td width=\'85\' height=\'15\' align=\'center\' valign=\'center\'><FONT face=\'Times New Roman\' color=\'white\' size=\'3\'><u>Saturday</u></font></td></tr>\";

echo \"<tr><td width=\'85\' height=\'85\' align=\'left\' valign=\'top\'></td>\";

echo \"<td width=\'85\' height=\'85\' align=\'left\' valign=\'top\'></td>\";

echo \"<td width=\'85\' height=\'85\' align=\'left\' valign=\'top\'><FONT face=\'Verdana\' color=\'white\' size=\'2\'><b>01 - </b><A HREF=\'main.php?page=view_entry.php&id=$id\'>$title</a></font></td>\";

}

 

mysql_close($db);

 

?>

 

 

<?php

 

include \"config.php\";

 

$db = mysql_connect($db_host,$db_user,$db_pass);

mysql_select_db ($db_name) or die (\"Cannot connect to database\");

/* We have now connected, unless you got an error message */

/* Lets display the current titles, so we can select one for editing */

$query = \"SELECT id, title FROM news WHERE date=\'2003-04-02\' ORDER BY id DESC\";

$result = mysql_query($query);

/* Here we fetch the result as an array */

while($r=mysql_fetch_array($result))

{

/* This bit sets our data from each row as variables, to make it easier to display */

$id=$r[\"id\"];

$title=$r[\"title\"];

/* Now lets display the titles */

echo \"<td width=\'85\' height=\'85\' align=\'left\' valign=\'top\'><FONT face=\'Verdana\' color=\'white\' size=\'2\'><b>02 - </b><A HREF=\'main.php?page=view_entry.php&id=$id\'>$title</a></font></td>\";

}

 

mysql_close($db);

 

?>[/php:1:df95bb1102]

 

A bit big, and can probably be shrunken and still work, but I don\'t care.

My problem is that it looks for data that was posted on the date of, let\'s say the 1st, but if there is no data that was posted on the first then the whole query doesn\'t show up, which means a chunk of my table would be missing.

 

So, is there any way to make it do something different if there is no data that has the date on the 1st?

 

Thanks.

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.