LHC Posted May 21, 2017 Posted May 21, 2017 (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 May 21, 2017 by ZeroHour
howartp Posted June 8, 2017 Posted June 8, 2017 Can you post a sample of your before and after tables?
paulote Posted May 7, 2018 Posted May 7, 2018 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!
SimonHooker Posted May 9, 2018 Posted May 9, 2018 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
Qwentalis Posted May 23, 2018 Posted May 23, 2018 Without knowing your SQL query, it is hard to help you.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now