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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.