How to Arrange PHP Recordsets in a Table
You can arrange recordsets in a PHP Web page by using basic PHP and MySQL code. Recordsets, within the MySQL database, are instances of data that reoccur throughout various fields of a table. Recordsets are automatically assigned based on conditions, and so the only configuration you include is the particular recordset you want to recall. You can recall a recordset in a variety of ways depending on your purpose.
Instructions
-
-
1
Open your PHP document in Notepad and scroll through the code to the place where you want to insert your arrangement table.
-
2
Copy and paste this basic table structure, as an example:
<table>
<tr><th>Column 1</th><th>Column 2</th></tr>
<?php do { ?>
<tr> <td><?php echo $row_name1['name1'];
?></td> <td><?php echo $row_name2['name2']; ?></td> </tr>
<?php } while ($row_events = mysql_fetch_assoc($recordset));
?></table> -
-
3
Replace "Column 1" and "Column 2" with the names for your table columns. Replace "recordset" with the recordset you want to recall, and "row_name1" and "row_name2" with the table references to pull. Replace "name1" and "name2" with the value names you want to use for the fields.
-
1
Tips & Warnings
Instead of "mysql_fetch_assoc," you can also use mysql_fetch_array, mysql_fetch_field, mysql_fetch_object, mysql_fetch_row, mysql_fetch_flags, mysql_fetch_len, mysql_fetch_name or mysql_fetch_type.