Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-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
 
Old April 22nd, 2005, 10:08 AM
Registered User
 
Join Date: Apr 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default load form with row which is fetched from mysql

I AM CONFUSE
PL. HELP

I WANT TO POPULATE MY FORM WITH THE INFO.FROM FETCHED
ROW FROM MYSQL DATABASE.

TO EDIT INFO BY USER AND UPDATE DB AGAIN.


CAN ANYBODY WILL HELP ME OUT???????????????/:(

 
Old April 24th, 2005, 07:41 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

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 :)

use $_REQUEST[] to get querystring data.

 
Old April 29th, 2005, 09:07 AM
Authorized User
 
Join Date: May 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to ruhin Send a message via AIM to ruhin Send a message via MSN to ruhin Send a message via Yahoo to ruhin
Default

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.

Bes of luck.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting a row in MySQL database mattw1100 Beginning PHP 3 August 21st, 2008 05:28 PM
ASP Total Records Fetched cancer10 Classic ASP Databases 3 October 20th, 2006 12:21 PM
MySQL - Returning "most popular" row whiffin SQL Language 4 November 2nd, 2004 10:04 AM
getting a specific row from a MySQL result set Tachyon Beginning PHP 3 July 12th, 2004 11:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.