Jump to content

[SOLVED] Hyperlink in Table for editing information


peranha

Recommended Posts

What I have is a table with 3 columns, and in the first column, I have it linked to editpost.php? with the id behind it.  I need to somehow get that id into the editpost page to bring up the info in 3 text boxes for the user to edit.  Not sure as to how to do this.

 

Here is the table info that they will click on to edit items.

 

<TR><TD WIDTH="225"><a href='editpost.php?<?PHP echo $row[0]; ?>'><?PHP echo $row[1]; ?></a></TD><TD WIDTH="460"><?PHP echo $row[2]; ?></TD><TD WIDTH="70" align="center"><?PHP echo $row[3]; ?></TD></TR>

 

Here is the edit page

 

// create query

$query1 = "SELECT * FROM table WHERE commid = ?";

 

Not sure as to what to put in the commid = ?.

 

If anyone can help, that would be great.

 

Thanks in advance.

You need to use the $_GET method to retrieve the id for each page.

 

Firstly, you need to change that link to something like editpost.php?comm=id

 

Then, you can select the result by inserting the following into your code:

 

$commid = $_GET['comm'];

 

Use $commid in your query, and all should work accordingly.

Edit: Beat to it :P

 

You need to change your clicking part to this

 

<TR><TD WIDTH="225"><a href='editpost.php?id=<?PHP echo $row[0]; ?>'><?PHP echo $row[1]; ?>[/url]</TD><TD WIDTH="460"><?PHP echo $row[2]; ?></TD><TD WIDTH="70" align="center"><?PHP echo $row[3]; ?></TD></TR>

 

Now on the page where you grabbing the information to edit, you would simply do this

 

<?php

$id = $_GET['id'];
$query1 = "SELECT * FROM table WHERE commid = $id";

?>

 

 

 

 

 

 

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.