Jump to content

help on setting condition for date()


pixeltrace

Recommended Posts

guys,

i need help on this one. kindly check
[a href=\"http://www.sinagtala.net/sinag3/index1.php\" target=\"_blank\"]http://www.sinagtala.net/sinag3/index1.php[/a]

check the events list in the upcoming events section that they
are already done, meaning they are already past events because
of the date.

i am having problem setting up the condition for the date of the events versus the system date.
the information being shown in the upcoming events is inside an iframe
what i wanted to happen here is if there are no events with there corresponding dates that are equal
to the system date or higher (meaning currentdate above) my if else condition will just change the display page on the iframe to noupcoming.php but if there is or are (no matter how few or many they are) it will change the displaypage on the iframe to upcomingmain.php

=========== here is the script that i made but i can't get the right codes.
<?
include 'db_connect.php';

$uSql = "SELECT event_date FROM events";
$uResult = mysql_query($uSql, $connection);
if(!$uResult){
echo 'no data found';
}
else{
while($uRow = mysql_fetch_row($uResult)){
$eventdate = $uRow[0];
$systemdate = date ();

if ($eventdate >= $systemdate) {$upcomingmain = 'upcomingmain';}
else {$upcomingmain = 'noupcoming';}
?>

<iframe id="upcomingmain" src="<? $upcomingmain ?>.php" width=302 height=225 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=yes></iframe>

====================

hope you guys can help me with this.

thanks in advance!!!

Link to comment
Share on other sites

[!--quoteo(post=354111:date=Mar 12 2006, 12:58 AM:name=pixeltrace)--][div class=\'quotetop\']QUOTE(pixeltrace @ Mar 12 2006, 12:58 AM) [snapback]354111[/snapback][/div][div class=\'quotemain\'][!--quotec--]
is that wrong?
i just assigned a variable for event_date ( uRow[0] )
any suggestions that would fix my problem?

thanks!
[/quote]

SELECT event_date FROM events WHERE event_date >= SYSDATE()
Link to comment
Share on other sites

greycap,

thanks it work!....
but just on the sql query part.
how can i make a condition wherein if there are no data wherein the
event_date >= sysdate ()
a word saying "no new updates" will appear on the screen
else if there are datas >= sysdate ()
it will just show the data content from the database

thank in advance!!
Link to comment
Share on other sites

try puttin youyour if statement into a function
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
function gotopage($url){
if ($eventdate >= $systemdate) {
$url = 'upcomingmain.php';
}
else {
$url = 'noupcoming.php';
}
}
?>

<iframe id="upcomingmain" src="<? echo "gotopage($url)";?>.php" width=302 height=225 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=yes></iframe>[/quote]

or something along that line hope this helps it might need some tweeking but in the end it should do what you want
Link to comment
Share on other sites

bro,

i can't make it work
here is the script that i made using the scripts that you've provided
==============
<?
include 'db_connect.php';

$uSql = "SELECT event_date FROM events";
$uResult = mysql_query($uSql, $connection);
if(!$uResult){
echo 'no data found';
}
else{
while($uRow = mysql_fetch_row($uResult)){
$eventdate = $uRow['event_date'];
} }
?>

<?
function gotopage($urls){
if ($eventdate >= $sysdate()) {$urls = 'upcomingmain.php';}
else {
$urls = 'noupcoming.php';}
} ?>

<iframe id="upcomingmain" src="<? echo "gotopage($urls)";?>.php" width=302 height=225 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=yes></iframe>

========================
are the variables that i have assigned is correct? what else needs to be done here?
thanks !!!!

Link to comment
Share on other sites

sorry i forgot to remove .php from your i frame [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<iframe id="upcomingmain" src="<? echo "gotopage($urls)";?>.php" width=302 height=225 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=yes></iframe>[/quote]with this code it would be calling for a page like this yourpage.php.php so it it wont work unless your page had 2 php extentions sorry about that try it like this [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<iframe id="upcomingmain" src="<? echo "gotopage($urls)";?>" width=302 height=225 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=yes></iframe>[/quote]
this should work if it doesnt try to change because that code should do what you want
Link to comment
Share on other sites

bro,

its still not working.... :((
could you try checking my codes if everything that's in here is correct?
=========
<?
include 'db_connect.php';

$uSql = "SELECT event_date FROM events";
$uResult = mysql_query($uSql, $connection);
if(!$uResult){
echo 'no data found';
}
else{
while($uRow = mysql_fetch_row($uResult)){
$eventdate = $uRow['event_date'];
$systemdate = sysdate();
}
}
function gotopage($urls){
if ($eventdate >= $systemdate) {$urls = 'upcomingmain.php';}
else {
$urls = 'noupcoming.php';
}
}
?>


<iframe id="upcomingmain" src="<? echo "gotopage($urls)";?>" width=302 height=225 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=yes></iframe>
==============

thanks a lot!!


bro,

i was able to make it work. but without the function
=========
<?
include 'db_connect.php';

$uSql = "SELECT event_date FROM events";
$uResult = mysql_query($uSql, $connection);
if(!$uResult){
echo 'no data found';
}
else{
while($uRow = mysql_fetch_row($uResult)){
$eventdate = $uRow['event_date'];
$systemdate = date('y-m-d');
}
}
if ($eventdate >= $systemdate) {$urls = 'upcomingmain.php';}
else {
$urls = 'noupcoming.php';
}
?>


<iframe id="upcomingmain" src="<?=$urls;?>" width=302 height=225 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=yes></iframe>
================

thanks for the help!!!
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.