If else

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Russ
Forum Newbie
Posts: 21
Joined: Tue Jun 25, 2002 3:33 pm

If else

Post by Russ »

basicly my problems is on the first if (sortby), when its called up, the else function also comes up too. heres my code, I can't see anything wrong with it, but then I am a newbie, also if I swap the first if (sortby) with the second (view), the else function comes up on the view if.

Code: Select all

if($_GETї'action'] == 'sortby')
{

$result = mysql_query("select * FROM interdb WHERE bandname LIKE '".strtoupper($_GETї'char'])."%' ORDER BY bandname ASC LIMIT 5",$db); 
while($myrow = mysql_fetch_array($result))

{
echo "<p><b><a href=?action=view&id=" .$myrow&#1111;id]. " class=link>" . $myrow&#1111;'bandname'] . "</a></b> <font class=rm>- " . date("F j", strtotime($myrow&#1111;'date'])) . "</font>";
echo "<br>" . $myrow&#1111;'preinter'];
echo "<br><b><font class=rm><a href=?action=view&id=" .$myrow&#1111;id]. " class=rm>...Read More</a></b></font>";

&#125;

&#125; 

elseif($_GET&#1111;'action'] == 'view') 

&#123;

$result = mysql_query("SELECT * FROM interdb WHERE id=$id",$db); 
$myrow = mysql_fetch_array($result); 

&#123;
echo( "<br><b>" . $myrow&#1111;'bandname'] . " Interview</b>"  );
echo( "<p>" . $myrow&#1111;'preinter'] );
echo( "<p>" . $myrow&#1111;'inter'] );

&#125;
&#125; 

else 

&#123;

$result = mysql_query("SELECT * FROM interdb ORDER BY id desc LIMIT 5",$db); 
while($myrow = mysql_fetch_array($result))

&#123;
echo( "<p><b><a href=?action=view&id=" .$myrow&#1111;id]. " class=link>" . $myrow&#1111;'bandname'] . "</a></b> <font class=rm>- " . date("F j", strtotime($myrow&#1111;'date'])) . "</font>" );
echo( "<br>" . $myrow&#1111;'preinter'] );
echo( "<br><b><font class=rm><a href=?action=view&id=" .$myrow&#1111;id]. " class=rm>...Read More</a></b></font>" );

&#125;
&#125;
Zmodem
Forum Commoner
Posts: 84
Joined: Thu Apr 18, 2002 3:59 pm

Post by Zmodem »

I don't know if this woudl have anything to do with it or not, but in this code:

Code: Select all

&#123;  <----
echo( "<br><b>" . $myrow&#1111;'bandname'] . " Interview</b>" ); 
echo( "<p>" . $myrow&#1111;'preinter'] ); 
echo( "<p>" . $myrow&#1111;'inter'] ); 

&#125; <----
delete the brackets indicated by the arrows. It's under the else if (_GET['action'] == 'view') section.

It looks kind like you have an extra set of { } when you don't need them. Might be goofing things up *shrug*
Russ
Forum Newbie
Posts: 21
Joined: Tue Jun 25, 2002 3:33 pm

Post by Russ »

I got it working now, I was a dumbass and and kept viewing the wrong file :oops: thanks for your help
Post Reply