Jump to content


Photo

if else condition help


  • Please log in to reply
1 reply to this topic

#1 pixeltrace

pixeltrace
  • Members
  • PipPipPip
  • Advanced Member
  • 577 posts

Posted 09 March 2006 - 03:05 AM

guys,

i need help again,
please check
[a href=\"http://www.sinagtala.net/sinag3/upcomingmain.php\" target=\"_blank\"]http://www.sinagtala.net/sinag3/upcomingmain.php[/a]
notice that the dates are not up to date already
what i mean is at has passed already.
what i wanted to happen there is
when the date is not up to date already
let say if the date that is specified there is not
from mar9 2006 onwards
there will be a message saying that
"no new updates"

this is the script that i used for that page
==========
<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<?
include 'db_connect.php';

$uSql = "SELECT event_update, event_image, event_title, event_description, event_imagelink FROM events ORDER by event_date DESC LIMIT 5";
$uResult = mysql_query($uSql, $connection);
if(!$uResult){
echo 'no data found';
}
else{
while($uRow = mysql_fetch_row($uResult)){
$event_imagelink = $uRow[4];
?>
<table width="285" border="0" cellspacing="0" cellpadding="0">

<tr>
<td colspan="5"><img src="images/spacer.gif" width="10" height="5" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2" align="left" valign="top"><span class="bodytext">
<?= $uRow[0]?>
</span></td>
<td width="10" rowspan="3"><img src="images/spacer.gif" width="10" height="10" /></td>
</tr>
<tr>
<td width="10" rowspan="2"><img src="images/spacer.gif" width="10" height="10" /></td>
<?
if ($uRow[1] == 1) { echo ""; }
elseif ($uRow[1] == 2){
echo '<td width="60" rowspan="2" align="center" valign="top">';
echo '<a href="images/events/'.$event_imagelink.'.jpg" target="_blank" class="fotgal"><img src="images/events/thumbs/'.$event_imagelink.'.gif" width="60" height="60" border="0" class="fotgal"></a>';
echo '</td>';
}?>
<td width="10" rowspan="2"><img src="images/spacer.gif" width="10" height="10" /></td>
<td width="270" align="left"><span class="bodytext3">
<?= $uRow[2]?>
</span></td>
</tr>
<tr>
<td align="left"><span class="bodytext1">
<?= $uRow[3]?>
</span></td>
</tr>
<tr>
<td colspan="5"><img src="images/spacer.gif" width="10" height="5" /></td>
</tr>

</table>
<?
}
}
?></td>
</tr>
</table>
=====================
hope you guys can help me with this.

thanks in advance!!!


#2 littlened

littlened
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 09 March 2006 - 01:38 PM

[!--quoteo(post=353116:date=Mar 9 2006, 03:05 AM:name=pixeltrace)--][div class=\'quotetop\']QUOTE(pixeltrace @ Mar 9 2006, 03:05 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
guys,

i need help again,
please check
[a href=\"http://www.sinagtala.net/sinag3/upcomingmain.php\" target=\"_blank\"]http://www.sinagtala.net/sinag3/upcomingmain.php[/a]
notice that the dates are not up to date already
what i mean is at has passed already.
what i wanted to happen there is
when the date is not up to date already
let say if the date that is specified there is not
from mar9 2006 onwards
there will be a message saying that
"no new updates"

this is the script that i used for that page
==========
<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<?
include 'db_connect.php';

$uSql = "SELECT event_update, event_image, event_title, event_description, event_imagelink FROM events ORDER by event_date DESC LIMIT 5";
$uResult = mysql_query($uSql, $connection);
if(!$uResult){
echo 'no data found';
}
else{
while($uRow = mysql_fetch_row($uResult)){
$event_imagelink = $uRow[4];
?>
<table width="285" border="0" cellspacing="0" cellpadding="0">

<tr>
<td colspan="5"><img src="images/spacer.gif" width="10" height="5" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2" align="left" valign="top"><span class="bodytext">
<?= $uRow[0]?>
</span></td>
<td width="10" rowspan="3"><img src="images/spacer.gif" width="10" height="10" /></td>
</tr>
<tr>
<td width="10" rowspan="2"><img src="images/spacer.gif" width="10" height="10" /></td>
<?
if ($uRow[1] == 1) { echo ""; }
elseif ($uRow[1] == 2){
echo '<td width="60" rowspan="2" align="center" valign="top">';
echo '<a href="images/events/'.$event_imagelink.'.jpg" target="_blank" class="fotgal"><img src="images/events/thumbs/'.$event_imagelink.'.gif" width="60" height="60" border="0" class="fotgal"></a>';
echo '</td>';
}?>
<td width="10" rowspan="2"><img src="images/spacer.gif" width="10" height="10" /></td>
<td width="270" align="left"><span class="bodytext3">
<?= $uRow[2]?>
</span></td>
</tr>
<tr>
<td align="left"><span class="bodytext1">
<?= $uRow[3]?>
</span></td>
</tr>
<tr>
<td colspan="5"><img src="images/spacer.gif" width="10" height="5" /></td>
</tr>

</table>
<?
}
}
?></td>
</tr>
</table>
=====================
hope you guys can help me with this.

thanks in advance!!!
[/quote]

If I'm understanding what you want to do correctly, then you need to alter your MYSQL SELECT command to something like.

$uSql = "SELECT event_update, event_image, event_title, event_description, event_imagelink FROM events WHERE event_date = '$somedate' ORDER by event_date DESC LIMIT 5";

then you need to set $somedate as the date you want to search, but remember to do it in the formation of yyyy/mm/dd and set the field in mysql to a date type.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users