AngN Posted September 13, 2007 Share Posted September 13, 2007 Hi, using PHP how can I show the results of a SQL query to look like this:- Name Address Delete Y/N Someone Somewhere Remove Code sample:- // Fetch each database table row of the results while($row = @ mysql_fetch_array($result)) { echo ("<p>" . $row["job_id"] ). ( $row["title"] ). ( $row["employer"] ) . ( $row["start_date"] ). ( $row["salary"] ) . ( $row["req_exp"] ) . ( $row["req_skills"] ) . ( $row["description"] ) . ( $row["remove"] ); } Also how can I make the word 'remove' link to another PHP file? I would be grateful for any help Link to comment https://forums.phpfreaks.com/topic/69134-formatting/ Share on other sites More sharing options...
recklessgeneral Posted September 13, 2007 Share Posted September 13, 2007 Hi, You would use a HTML table, with the first row containing <th> elements for the headings, then use your while loop to extract the data. Each iteration of the loop would be in a <tr> and each item would be in a <td></td> pair of tags: <table> <tr> <th>Name</th> <th>Address</th> <th>Delete Y/N</th> </tr> <?php // Fetch each database table row of the results while($row = @ mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['address'] ."</td>"; echo "<td><a href=\"remove.php?id=" . $row['job_id'] . "\">Remove</a></td>"; echo "</tr>"; } ?> </table> The 'Remove' has been made into a link using the <a> tags, and links to a page named remove.php. The '?id=...' part allows the chosen job to be passed through to the remove.php page, which can then be obtained using $_GET['id']. Hope this helps, Darren. Link to comment https://forums.phpfreaks.com/topic/69134-formatting/#findComment-347592 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.