Hello theScripts, i've been using a lot of tutorials and forum reads here, so i figured it was time i joined. I've found everything here nothing but helpful.
I was wondering if you all could give me a hand on this. (if this is suppose to be in MySQL forum i apologize in advance).
I'm trying to make a "School Closing" alert for a school website, like when it snows. Pretty much, I made a simple form for a secretary to input into with a title and content. Her info goes into a MySQL table (named 'alert') with the fields title, content, datetime (which is set to timestamp with auto_update), and id (auto_increment ).
Pretty much, i want the query to look at the table, if something was put in today, make a div on the site with the conent. If nothing was put in, it wont make a div. Simple.
Somehow, i need the query to check if the post was put in today between midnight and 11:59pm today. So once midnight hits tomorrow, it won't find anything.
I had this concept
[PHP]
<?php
$today = date("j, n, Y");
$query = mysql_query("SE LECT * FROM `alert` WHERE datetime = $today ORDER BY `id` DESC LIMIT 0 , 1");
while($row = mysql_fetch_arr ay($query)) {
echo '<div id="alert" style="backgrou nd:red;border:2 px solid #000;"><h1>'.$r ow['Title'].' - '.$row['datetime'].'</h1><p>'.$row['Alert'].'</p></div>';
}
?>[/PHP]
Now in thereory this should work, needless to say...it isn't though. I have the limit set to the first id because if she wanted to make a change to the current alert, all she has to do is retype and it will pick the top one.
Let me know what you all this, and thanks in advance.
I was wondering if you all could give me a hand on this. (if this is suppose to be in MySQL forum i apologize in advance).
I'm trying to make a "School Closing" alert for a school website, like when it snows. Pretty much, I made a simple form for a secretary to input into with a title and content. Her info goes into a MySQL table (named 'alert') with the fields title, content, datetime (which is set to timestamp with auto_update), and id (auto_increment ).
Pretty much, i want the query to look at the table, if something was put in today, make a div on the site with the conent. If nothing was put in, it wont make a div. Simple.
Somehow, i need the query to check if the post was put in today between midnight and 11:59pm today. So once midnight hits tomorrow, it won't find anything.
I had this concept
[PHP]
<?php
$today = date("j, n, Y");
$query = mysql_query("SE LECT * FROM `alert` WHERE datetime = $today ORDER BY `id` DESC LIMIT 0 , 1");
while($row = mysql_fetch_arr ay($query)) {
echo '<div id="alert" style="backgrou nd:red;border:2 px solid #000;"><h1>'.$r ow['Title'].' - '.$row['datetime'].'</h1><p>'.$row['Alert'].'</p></div>';
}
?>[/PHP]
Now in thereory this should work, needless to say...it isn't though. I have the limit set to the first id because if she wanted to make a change to the current alert, all she has to do is retype and it will pick the top one.
Let me know what you all this, and thanks in advance.
Comment