Jump to content


Photo

help on setting condition for date()


  • Please log in to reply
8 replies to this topic

#1 pixeltrace

pixeltrace
  • Members
  • PipPipPip
  • Advanced Member
  • 577 posts

Posted 12 March 2006 - 03:22 AM

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!!!



#2 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 12 March 2006 - 04:54 AM

what format is
$eventdate = $uRow[0];

Lite...

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

#3 pixeltrace

pixeltrace
  • Members
  • PipPipPip
  • Advanced Member
  • 577 posts

Posted 12 March 2006 - 06:58 AM

is that wrong?
i just assigned a variable for event_date ( uRow[0] )
any suggestions that would fix my problem?

thanks!

#4 greycap

greycap
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 12 March 2006 - 09:25 AM

[!--quoteo(post=354111:date=Mar 12 2006, 12:58 AM:name=pixeltrace)--][div class=\'quotetop\']QUOTE(pixeltrace @ Mar 12 2006, 12:58 AM) View Post[/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()

#5 pixeltrace

pixeltrace
  • Members
  • PipPipPip
  • Advanced Member
  • 577 posts

Posted 14 March 2006 - 05:58 PM

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!!


#6 shortj75

shortj75
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationPort Huron,mi

Posted 14 March 2006 - 06:17 PM

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
The Short One

hopfully this helps if it doesn't sorry
i won't write the code for you!!! you don't learn that way

#7 pixeltrace

pixeltrace
  • Members
  • PipPipPip
  • Advanced Member
  • 577 posts

Posted 15 March 2006 - 02:19 AM

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 !!!!



#8 shortj75

shortj75
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationPort Huron,mi

Posted 15 March 2006 - 07:46 AM

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
The Short One

hopfully this helps if it doesn't sorry
i won't write the code for you!!! you don't learn that way

#9 pixeltrace

pixeltrace
  • Members
  • PipPipPip
  • Advanced Member
  • 577 posts

Posted 15 March 2006 - 05:27 PM

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!!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users