thwikehu1990
-
Posts
3 -
Joined
-
Last visited
Posts posted by thwikehu1990
-
-
My error is just my while echo appearing in and out of my tables on the page.
-
Hi all!
I've been recently messing with PHP and MySQL to attempt to create a search function for my tables (too advanced, so I toned it down to learning to just display data from my table). Anyways, I'm watching a YouTube video on how to do it, and I'm copying his code exactly, but I'm still getting an error.Can anyone help? Thanks.
Edit: Sorry, my error was snuggled down below the code. Anyways, my error is just my while echo appearing in and out of my tables on the page.
My code:
<?php //Make connection mysql_connect('localhost', 'root', 'test'); // select db mysql_select_db('testdatabase'); $sql="SELECT * FROM employees"; $records=mysql_query($sql); ?> <html> <head> <title>Employee Data</title> </head> <body> <table width="600" border="1" cellpadding="1" cellspacing="1"> <tr> <th>ID</th> <th>First name</th> <th>Surname</th> <th>Age</th> </tr> <?php while($employees=mysql_fetch_assoc($records)){ echo "<tr>"; echo "<td>".$Employee['ID']."</td>"; echo "<td>".$Employee['First name']."</td>"; echo "<td>".$Employee['Surname']."</td>"; echo "<td>".$Employee['Age']."</td>"; echo "</tr>"; } // end while ?> </table> </body> </html>
Displaying Data from a Table
in PHP Coding Help
Posted
The contents of that while loop appear as text on my web page.