I am trying to create a table in a HTML Document using php, and here is my code:
<p>Below is the table of all the books available: <br />
<table border="1" ><th>Book ID</th><th>Subject</th><th>Title</th><th>Print Edition</th><th>Condition</th><th>Asking Price</th>
<?php
$server= 'MYSERVER';
$user = 'MYUSERNAME';
$password = 'MYPASSWORD';
$database = 'MYDBNAME';
$mysqli = new mysqli('server', 'user', 'password', 'database');
foreach ( $mysqli->query('SELECT user,host FROM mysql.user') as $row )
{?>
<tr><td><?php echo $res['ID'];?></td><td><?php echo $res['Subject'];?></td><td><?php echo $res['Title'];?></td><td><?php echo $res['PrintEdition'];?></td><td><?php echo $res['Cond'];?></td><td><?php echo $res['Price'];?></td></tr>
<?php }
mysqli_close($mysqli);
?>
</table>
<br />
If you like to request any of these titles, Do the following:
. . . .
However, it seems I'm not sure what is happening, but I am having this as the outcome on my Chrome (this is the actual screen shot of my webpage):
Below is the table of all the books available: query('SELECT * FROM entry_database') as $row ) {?> Book ID Subject Title Print Edition Condition Asking Price
(The above row looks like a table)
If you like to request any of these titles, Do the following:
I'm not sure why this is happening, but I have a hunch that it is because HTML treats the -> as a tag. Is there any way of fixing this?
Just to explain, I have looked at all the answers, tried all the answers, and as far as I am aware, I can't find the answer.
Many thanks in advance.
UPDATE 1:
So I managed to sort out the additional code showing, thanks to @Fred -ii-
However, the data is not showing. I tried the following to output the date, but no success:
foreach ( $mysqli->query('SELECT * FROM entry_database') as $row )
{?>
<?php echo $row['ID'];?><br /><?php echo $row['Subject'];?><br /><?php echo $row['Title'];?><br /><?php echo $row['PrintEdition'];?><br /><?php echo $row['Cond'];?><br /><?php echo $row['Price'];?><br />
<?php }
mysqli_close($mysqli);
?>
We are getting there, I am sure