Jump to content

Recommended Posts


<?php  
$booked = "<b>Seat Booked</b>";
   
   $sql = "SELECT id,username,admin,rowId,columnId FROM seats ORDER by id ASC";  

   $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); 

   while(list($id,$username,$admin,$columnId,$rowId,)=mysql_fetch_row($result)){
   
   

  
   if($columnId == 'BOX' && $rowId == 1) {
   echo '<p></p>'."\n";
   }


if($admin==1){ 
      



       

echo '<div style="background-color:red;align:center;width:60px;text-align:center;float:right;height:40px;border:2px solid #FFFFFF;"><b><font color="black">'.$rowId.''.$columnId.'</div>'."\n";    
   
   }

if($admin==0){  


       $checked = ($admin==1) ? 'checked="checked"' : ''; 
    
      echo '<div style="background-color:green;align:center;width:60px;font-weight:bold;text-align:center;float:right;height:40px;border:2px solid #FFFFFF;"><b><font color="black">'.$rowId.''.$columnId.'<input type="checkbox" name="admin[]" value="'.$id.'"  /></div>'."\n";  
   
   
}

}


   ?>  

 

 

Please notice the "    if($columnId == 'BOX' && $rowId == 1) " part of my code. The rest of it is all running as I would like, and even with this bit of code in, it is still working too. However, as you will probably guess, I want the code to echo a new div ( serving the purpose of a gap on the page) if the column ID (from my database) is equal to BOX. However, nothing is happening. I have also tried the same technique using <P>.

 

Any ideas why it's not working?

 

Thanks in advance

 

Dan

 

Link to comment
https://forums.phpfreaks.com/topic/150852-help-with-an-if/
Share on other sites

No you're not - you're requesting ORDER by id ASC which means when your query starts pulling data from the table it'll start with the lowest id then work its way up.

 

You're then checking IF a field contains BOX.

 

If you want to pull out the one with "BOX" you'll need to change your query...

SELECT id,username,admin,rowId,columnId FROM seats WHERE columnId='BOX'

Link to comment
https://forums.phpfreaks.com/topic/150852-help-with-an-if/#findComment-792505
Share on other sites

Yes - in your IF you're checking for BOX against ID=1 which never will happen because BOX is associated with another ID.

 

You need to change your IF to maybe this then:

   if($columnId == 'BOX') {
   echo '<p>Found BOX in ID '.$id.'</p>'."\n";
   }

 

(I've added some extra code in the echo to show you where BOX was found.)

Link to comment
https://forums.phpfreaks.com/topic/150852-help-with-an-if/#findComment-792521
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.