Jump to content

Recommended Posts

Posted (edited)

Hi All,

 

Wondering if someone can point me in the right direction. Currently I have a table with several columns with names such as A1, A2, A3 etc and I've found that doing it this way no longer works with the new database structure I want to use. The A1, A2, A3.. will now be listed within the actual column.

 

I have included the current code I am, using to get this information, but I don't know how to loop through the column there the A1, A2.. are and get the information on the same row.

 

$i=1;            
$row = mysqli_fetch_assoc($result);    
while ($i < 6)    {
           if($row["MON".$i.""]=='FREE')        {
       print "
Available";
       }
       else        {
           if($row["MON$i"]==$logon_name)            {
           echo $i;
           print"".$row["MON". $i. ""];
           print "
". $row["MONCLASS".$i.""];
           print "

Cancel";
           print "";
           }
           else            {
           print"".$row["MON". $i. ""];
           print "

". $row["MONCLASS$i"];
           print "";
           }
       }
     $i++;}}
?>

 

 

Any pointers would be great.

 

Luke

Edited by ZeroHour
  • 3 weeks later...
  • 10 months later...
Posted

Hi!...in the second "if" statement... it should be "MON".$i instead of "MON$i" . The same below in the penultimate print line, should be $row["MONCLASS".$i]

 

Hope it helps!

Posted

As far as I am aware, the following are all identical in PHP due to strings in double quotes being evaluated. Single quotes are not evaluated. Typically I always preferred to single-quote so that variables didn't accidentally get evaluated. This may have changed in the last many years though, haven't really used PHP lately that much!

 

"MON".$i

"MON$i"

"MON".$i.""

'MON'.$i

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...