perfect form

General discussions related to php

Moderators: macek, egami, gesf

Post Reply
liderbug
New php-forum User
New php-forum User
Posts: 20
Joined: Mon Feb 14, 2011 7:14 pm

Re: perfect form

Post by liderbug » Thu Sep 05, 2013 1:30 pm

Sounds like something I've got - it starts with a table (spreadsheet) id, first, last, email...... and each line starts:
<a href=edit.php?id=$id>$id</a> </td><td>$first......

At the top of the script:

13 $list = array ('id', 'first', 'last', 'delivery', 'misc',
14 'renew', 'address', 'city', 'state', 'zip', 'route',
15 'email', 'zone', 'phone', 'update', 'delete');
16 foreach ($list as $item) {
17 $$item = $_GET ["$item"];
18 }
Is how I return everything.
20 echo "<input type=hidden name=id value=$id>";

23 mysql_connect ("local.....
24 mysql_select_db ("mydb...

25 if ( "$update" == "Update" )
26 {
27 $query = "update table set first='$first',last='$last'....where id=$id;
28 $mres1 = mysql_query ($query); myres1 = 1 of update worked


35 $query = "select * from table where id = '$id';";
36 $mres1 = mysql_query ($query);
37 $cust = mysql_fetch_row ($mres1);

Then rebuild the form:
echo "<table... <tr... <td... $cust[0] ... $cust[1]...
<input type=submit...
<input type=button Back...

So then I go to the main web page I get
1 Tom Jones em@ail.com...
2 Mary Smith her@email.com
3 Bill....

The leading numbers (1,2,3,...) are a link to edit.php. The id is passed to edit.php where it does select * from table where id = $id; then build the form with data filled in. Anything can be changed (ie it's "Robert" not "Bob", it's 22 Twain not 22 Wain) and hit Submit which saves the changes and redisplays the form. This is kind of high level with a lot of details missing but then your details and my details are prob. not the same. The main web page is not editable, only the form showing one person is.

Hope this can help.
Chuck

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest