Jump to content

Formatting


AngN

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.