Create a form for editing the record
Then on the display funtion just put a link on each record to that form
and pass the id of that record like <a
href="editrecord.php?id=<?=$row['id']?>">edit</a>
On the edit form just grab the data of the $id passed on the url and put
those values on the input fields like <input type="text" name="field1"
value="<?=$row['field1']?>">
Than just save the form result into the database with an UPDATE
tablename SET filed1='$field1' ... WHERE id='$id'); ...

Dont' forget the bit of code here are just examples and very insecure
... 
Need to work on the validation etc... 
 
Humberto Silva
World Editing
Portugal
 


-----Original Message-----
From: Louie Miranda [mailto:[EMAIL PROTECTED] 
Sent: quinta-feira, 15 de Janeiro de 2004 8:00
To: [EMAIL PROTECTED]
Subject: [PHP-DB] sql query, editing?


I have this code below, it fetches data on a mysql database. I was
hoping you could give me a code hint on where could, my goal is to
display this data on a browser which i did already and be able to edit
it via a form.

edit? -> table1=value -> table2=value

I dont know where to start. please help me, i hope i can display all the
data and have a button for editing and catch which one to edit.


## code ##
$result = mysql_query("select
product_code,title,language,issue,category,cost from iip_t_cp where
issue = $issue and category = '$category' and language = '$language' and
depleted = '$depleted'", $connect); $num_rows = mysql_num_rows($result);

function display($result)
  {
    echo "<h1>pricelist records</h1>\n";
    echo "<br>";
    echo "\n<table cellspacing=3 cellpadding=3 border=1>\n<tr>\n" .
         "\n<th>product
code</th><th>title</th><th>language</th><th>issue</th><th>category</th><
th>c
ost</th>" .
         "\n</tr>";

      while ($row = @ mysql_fetch_row($result))
        {
          echo "\n<tr>";
          foreach($row as $data)
          echo "\n\t<td> $data </td>";
          echo "\n</tr>";
        }

    echo "\n</table>";
}
display($result);
## code ##




-- -
Louie Miranda
http://www.axishift.com

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to