FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


show items posted for today only, php and mysql





spider
ok, I should know this,, all I want this script to do, is take information from a database and post it for the same day,, and not tomorrow... like items posted today,,,,

here the code I have,, some of it, I dont even think I need... like the date stop....

[php]

<?
$d = date("m|d|Y");

$que = "SELECT * FROM class_item WHERE d_start='$d'";
$res = mysql_query($qu);
$num = mysql_num_rows($re);

while($ro = mysql_fetch_array($res)){
$dur = 7;
list($m,$d,$y)= split ("\|", $ro['d_start'], 3);
list($dd,$mm,$yyyy) = split("-",date("d-m-Y",time()));
$today = mktime(0, 0, 0, $mm, $dd, $yyyy);
$d_end = mktime(0, 0, 0, date("m"), date("d")+$dur, date("y"));
$ds = date('m/d/Y',$d_end);

if($ds <= $today){
echo '
<TABLE CELLSPACING="0" CELLPADDING="4" BORDER="0" WIDTH="100%"><TR><TD ALIGN="left" VALIGN="TOP" WIDTH="20%">
<a href="http://'.$domain.'/c/results.php?desc=1&id='.$row['id'].'">
<img src="http://'.$domain.'/c/image/'.$ro[image].'" border="0" height="60" width="60"></a>
</td><td>
<font size="2"><b> <a href="http://'.$domain.'/c/description.php?id='.$ro['id'].'">'.$ro[title].'</a></B></font>
</td></tr></table>
<HR>
';
}else{
echo "Sorry, No Ads for ".$ro['d_start']."!";
}

}

?>

[/php]
Any suggestions?
ncwdavid
Your supposed to use the "
Code:
[code][/code]
" to post any code. And not using that makes it harder to read code anyways. Ill have a look at the code later and then see what i can come up with. Someone will probly get here before me anyway.
hexkid
Quote:
<?

Better to use "<?php". If you ever move your script to some server that has short_open_tags disabled it will not work.

Quote:
$d = date("m|d|Y");

$que = "SELECT * FROM class_item WHERE d_start='$d'";

Oops! Are you sure your `d_start` column is formatted as "m|d|Y"?

Quote:
$res = mysql_query($qu);

No `$qu` defined. If you had added the line in my sig to the top of your script, PHP itself would let you know about it

Quote:
$num = mysql_num_rows($re);

What if the mysql_query() call failed and returned false? You really should test the mysql_query() result, like this
Code:
// ...
$res = mysql_query($qu);
if ($res === false) {
  // Query failed.
  // For simplicity sake, print the error and exit
  exit('Error in query: ' . musql_error());
}
// ...


Solve this problems and post again if you still need help
spider
simple mistake on the [code]/[php]... hmmm

thanks hexkid, i got it to work,,, simply put,, pretty much same way you suggested,, and as for the php start <? Ive always used that,,, never accured to me to use the <?php ...
thanks...
Related topics
PHP, MySQL...
ASP +PHP+MySQL Tutorials
what is your php mysql apache installer package
Need some php/mysql dlls
The Basics (php, mysql etc)
What is useful way in this php+mysql problem?
PHP/Mysql - beginner!
A very good PHP MySQL Tutorial
Setup php,mysql and others...
php, mysql and iis5
 EASY 40 frih$ IF YOU KNOW PHP+MySQL 
Php Mysql security testing
Project to join - php,mysql??
knowing php/mysql, Is CGI/Perl worth learning?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.