Beginning PHPBeginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
May ( or may not ) get something in querystring ( or use other method ) and do a SELECT query:
$query="SQL SELECT WHERE statement";
$row=mysql_fetch_array(mysql_query($query));
or
$row=mysql_fetch_array($query);
then use value='$row[mysql_field_name]' in input or checkbox(s), radio(s); I hope, you'll manage :)
Hi,
I can give you an example. Say, I have a customer table. I want to give the customers option to change their information. For this I query from the database and take the info.
<code>
$sql = "SELECT * FROM customers WHERE customer_id = '$cid'";
</code>
this $cid comes from the selection of previous page. Then useing some functions I fetch the info.
<code>
$sql_res = mysql_query($sql);
$c_info = mysql_fetch_array($sql_res);
</code>
Now i have the row in the $c_info array. Now create your edit or update form and populate that.
<code>
<form action="update.php" method="POST">
Name :<input type=text name=id value="<?php echo $c_info['id']; ?>">
Address : <input type=text name=addr value="<?php echo $c_info['id']; ?>">
.
.
.
.
</code>
The information can be edited by the user.
Then the next script that would update the information ( i.e. update.php) should have the sql queries to fetch the information from the previous page and update the db table accordingly.