A friend is busy with a website and asked me how to create a table with hyperlinks using PHP/mySQL so in this Weekly Source Code edition I will explain just how.
First you need to connect to the database, for this you use the mysql_connect method, then you run your select SQL query and ouput the result in HTML.
See the sample code.
- I pass the record id to the updateuser.php page, this is so that the page know which user I wish to update.
- I refer to the record in the row via its field name, you can also refer via its record position in the result for example: $row refer to "Firstname" field.
- This will display all the records in the table, you can add some paging to the table to only display like 10 records at a time.
- For basic PHP you output HTML this way where your PHP and HTML code get mixed, its generally a good idea to use a template framework like Smarty where application code is seperated from the presentation.
PHP mySQL Functions