Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

perfect form

General discussions related to php

Moderators: macek, egami, gesf

perfect form

Postby ranonymus » Wed Jun 26, 2013 7:24 am

hello everyone,

im new here and i need help to complete a job.

the thing is:

i need a form that pulls data from database and then after the submit button it will save it to another table.

the form will have 3 selects that are connected, all of them are filled with a table info. when the first one is choosen the second one will appear and so on. also the form will have to save the text from the selects, not the value:

Code: Select all
  echo ("<option value=\"$row[cod_ano]\ " . ($ano == $row["cod_ano"]? " selected" : "" ) . "> ".$row['nome_ano'] . "</option>");
   


i need to save the .$row['nome_ano'] but it saves the .$row['cod_ano'], and if i change it the 2nd one doenst work.
this is getting my crazy allready...

can any1 help???

thanks.
ranonymus
New php-forum User
New php-forum User
 
Posts: 2
Joined: Tue May 28, 2013 7:21 am

Re: perfect form

Postby 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
liderbug
New php-forum User
New php-forum User
 
Posts: 20
Joined: Mon Feb 14, 2011 7:14 pm


Return to PHP General

Who is online

Users browsing this forum: No registered users and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.