Posted by J.O. Aho on 10/18/07 18:10
Arne Essa Madsen wrote:
> Need help to idea for how to make the following procedure or function:
>
> What I have:
> On the screen I have a simple list with with the most important fields
> of a the records in an MySQL database.
>
> What I want to do:
> I want a program/function/procedure so I can click a link in each record
> and then jump to a form showing all the fields.
while you type out the most important columns for the row, make a link to a
second page with the line ID
while($row=mysqli->fetch_array()) {
echo "<a href=\"otherpage.php?id={$row['id']}\">Row {$row['id']}:</a>\n";
//do your code for the columns you did want to show
}
On the otherpage.php you can then do:
$query="SELECT * FROM table WHERE id={$_GET['id']}";
> Why I want to do it:
> So I can see all the fields in the record, Or edit the data in the form
>
> The problem:
> The problem is NOT the program for the list or the form "Show record" or
> the form "Edit record"
>
> What I would like to get here:
> Either the idea for how to implement this program/function/procedure or
> a complete program/function/procedure to do it.
>
> This request may be boiled down to:
> How can I extract the record number from a simple database list so I can
> use it to a search or to select a specific record.
You use the ID column which you have an auto_increment, if you don't have any
primary key (in which case you use that one), if you don't have anything that
makes a row unique, then it's most likely you have a bad database design and
you should start all over with the database.
--
//Aho
[Back to original message]
|