I have Hotels and Customers tables (mysql) which gives information about which customer stayed in which hotel.
Here is the info
Table: Hotels
Hotel ID
Hotel Name
Table: StayedIn
StayedInID:
CustomerID:
StayedIn: (HotelID)
What I need is to give report where each customer stayed in like below
==============================================
Customer Hotel1 Hotel2 Hotel3 Hotel4
1 X Yes X X
2 X X Yes X
3 Yes X Yes X
I can get the data from MYSQL and present it as below
===============================================
Customer
1 Hotel2
2 Hotel3
3 Hotel1 Hotel3
How can I create an if condition that would help me to create a table which lists X and Yes automatically like the first table. For example: For customer 1, from the array, it knows he did not stay in Hotel1 so put an X for it between <td></td>, For Hotel 2, well he stayed, hotel 3 put an X.
The if condition I created which works for the first data shown below, however it repeats the X's.... Could you give me a hand on this?
Thank you in advance,
if ($StayedId== 1) { echo "<td>"; echo "Yes"; echo "</td>"; } if ($StayedId> 1) { echo "<td>"; echo "X"; echo "</td>"; }
if ($StayedId== 2) { echo "<td>"; echo "Yes"; echo "</td>"; } if ($StayedId > 2) { echo "<td>"; echo "2 X"; echo "</td>"; }
if ($StayedId== 3) { echo "<td>"; echo "Yes"; echo "</td>"; } if ($StayedId > 3) { echo "<td>"; echo "3 X"; echo "</td>"; }
if ($StayedId== 4) { echo "<td>"; echo "Yes"; echo "</td>"; }
Here is the info
Table: Hotels
Hotel ID
Hotel Name
Table: StayedIn
StayedInID:
CustomerID:
StayedIn: (HotelID)
What I need is to give report where each customer stayed in like below
==============================================
Customer Hotel1 Hotel2 Hotel3 Hotel4
1 X Yes X X
2 X X Yes X
3 Yes X Yes X
I can get the data from MYSQL and present it as below
===============================================
Customer
1 Hotel2
2 Hotel3
3 Hotel1 Hotel3
How can I create an if condition that would help me to create a table which lists X and Yes automatically like the first table. For example: For customer 1, from the array, it knows he did not stay in Hotel1 so put an X for it between <td></td>, For Hotel 2, well he stayed, hotel 3 put an X.
The if condition I created which works for the first data shown below, however it repeats the X's.... Could you give me a hand on this?
Thank you in advance,
if ($StayedId== 1) { echo "<td>"; echo "Yes"; echo "</td>"; } if ($StayedId> 1) { echo "<td>"; echo "X"; echo "</td>"; }
if ($StayedId== 2) { echo "<td>"; echo "Yes"; echo "</td>"; } if ($StayedId > 2) { echo "<td>"; echo "2 X"; echo "</td>"; }
if ($StayedId== 3) { echo "<td>"; echo "Yes"; echo "</td>"; } if ($StayedId > 3) { echo "<td>"; echo "3 X"; echo "</td>"; }
if ($StayedId== 4) { echo "<td>"; echo "Yes"; echo "</td>"; }