- This topic is empty.
-
AuthorPosts
-
November 20, 2013 at 11:26 pm #156769
moer
ParticipantLooking for some advice how to view like this not like this
For reference:-
//this is how i create the table
mysql_query(“CREATE TABLE example(
roomtype VARCHAR(30),
Jan1 INT,
Jan2 INT,
Jan3 INT)”)
or die(mysql_error());// this is how i insert the data into the table
mysql_query(“INSERT INTO example
(roomtype, Jan1, Jan2, Jan3) VALUES(‘Deluxe’, ‘255’, ‘255’, ‘255’ ) “)
or die(mysql_error());mysql_query(“INSERT INTO example
(roomtype, Jan1, Jan2, Jan3) VALUES(‘Suite’, ‘330’, ‘330’, ‘330’ ) “)
or die(mysql_error());// This is where my problem how to view the data as per link
$result = mysql_query(“SELECT * FROM example”)
or die(mysql_error());$row = mysql_fetch_array( $result );
echo “roomtype: “.$row[‘roomtype’];
echo ” Jan1: “.$row[‘Jan1’];
echo ” Jan2: “.$row[‘Jan2’];
echo ” Jan3: “.$row[‘Jan3’];.
November 20, 2013 at 11:55 pm #156771danramosd
ParticipantYou want to use an HTML table. Where you have the 4 lines that echo out the values you will want to change that to this:
<table> <tr> <th></th> <th colspan='3'>January</th> </tr> <tr> <td><?php echo “roomtype: “.$row['roomtype']; ?> </td> <td><?php echo ” Jan1: “.$row['Jan1']; ?> </td> <td><?php echo ” Jan2: “.$row['Jan2']; ?> </td> <td><?php echo ” Jan3: “.$row['Jan3']; ?> </td> </table>
November 21, 2013 at 2:10 am #156779moer
ParticipantTried it. The html table works but the php only pulls the variable only with no data. So i can see roomtype, Jan1, Jan2 & Jan3 nicely in place. However the data Deluxe, 255, 255, 255 are not generated.
Any idea?
November 21, 2013 at 7:42 am #156792danramosd
Participant<table> <tr> <th></th> <th colspan='3'>January</th> </tr> <?php while( $row = mysql_fetch_array( $result ) ){ ?> <tr> <td><?php echo “roomtype: “.$row['roomtype']; ?> </td> <td><?php echo ” Jan1: “.$row['Jan1']; ?> </td> <td><?php echo ” Jan2: “.$row['Jan2']; ?> </td> <td><?php echo ” Jan3: “.$row['Jan3']; ?> </td> </tr> <?php } ?> </table>
Try that. If it doesn’t work you might not have any data in your array. To find out if that’s true try running
<?php print_r( $row ) ;?>
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.