Display data taken from a database in another form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
heshan
Forum Commoner
Posts: 26
Joined: Tue Jul 13, 2010 1:16 pm

Display data taken from a database in another form

Post by heshan »

Hi all,

I want to display data which is in my database. But i want to display them in text boxes in another form.

For an example an officer enters data about a particular customer. Then he submitted the form to a supervisor. When supervisor logged in, he wants to modify data if needed.

I want to know is it possible to do?

Thanks,
Heshan.
User avatar
novito
Forum Commoner
Posts: 26
Joined: Mon Apr 07, 2008 11:08 am

Re: Display data taken from a database in another form

Post by novito »

Hi,

Retrieve the data from the database and put it in the the fields of the form. There is an option in the form fields called "default".

For example:

<input type="text" value="hello" />

I hope this helps.
User avatar
novito
Forum Commoner
Posts: 26
Joined: Mon Apr 07, 2008 11:08 am

Re: Display data taken from a database in another form

Post by novito »

Let me clarify,

Imagine that you have retrieved the data into a variable called $row.

If you wanted to show the email, you would do:

<INPUT TYPE="text" NAME="Email" VALUE="<? print $row["Email"] ?>">

Hope this helps :]
heshan
Forum Commoner
Posts: 26
Joined: Tue Jul 13, 2010 1:16 pm

Re: Display data taken from a database in another form

Post by heshan »

Thanks for your idea. It seems a good one. But i have problem of doing that. This is my coding regarding retrieval of data. Can you please check and see how it should be arranged properly.

Code: Select all

<?php

$connect=mysql_connect("localhost","root","");
mysql_select_db("bank",$connect) or 
   die ("could not select database");
   
$query = "select * from customer";
$result = mysql_query($query) or die(mysql_error());
while ($row=mysql_fetch_array($result)){
	  $row['nic']  ;
	  $row['full_name'] ;
	  $row['name_with_initials'] ;
	  $row['address'] ;
	  $row['contact_number'] ; 
	  $row['gender'];
	 
	
}
?>
This is one field of the form. Can you please how this line could be modified.

Code: Select all

<input type="text" name="nic" size="30"  class="attribute1" / >
Thanks,
Heshan.
User avatar
novito
Forum Commoner
Posts: 26
Joined: Mon Apr 07, 2008 11:08 am

Re: Display data taken from a database in another form

Post by novito »

If I understood what you are trying to do....

I believe that what you want is to retrieve data from the database for a particular customer. Therefore you might want to change the SQL to something like:

select * from customers where customer.id = $whatever .. Where whatever is the customer you want to retrieve data.

Once you have retrieved the data (for example into the variable $row), then what you want to do is show it to the form, and to do that you want to modify the value attribute in an input field...

If you could clarify what you are trying to do, I will try to be more helpful...

:)
heshan
Forum Commoner
Posts: 26
Joined: Tue Jul 13, 2010 1:16 pm

Re: Display data taken from a database in another form

Post by heshan »

This is a part of a project. I will give more details....

A junior staff member opens an account for a particular customer. The details of the customer should go into the database under customer table.

The customer details should be verified by a supervisor. When the supervisor logged into the system he has a separate function called " Modify account details". The entered data should be displayed to the supervisor in order to verify or modify.

This is what i try to do. Hope you got an idea and give me a solution. Thanks for the support.... :D :D


Heshan,
User avatar
novito
Forum Commoner
Posts: 26
Joined: Mon Apr 07, 2008 11:08 am

Re: Display data taken from a database in another form

Post by novito »

Hi!

I would ask the supervisor to give the name of the customer he wants to modify. Once you have the name/id/nickname or whatever is the way you want to retrieve the data I would get the information from the database using that value and show the content of the information into the form (check my first post to throw the data into each form field).

If you want the supervisor to receive all the new "customers" I would have a field (integer for example) in the database table that would be something like "verified", which value would be 0 in case of non-verified and 1 in case of verified. Then everytime the supervisors logs in, I would show him the customers that have the field "verified" with value 0. How I would show that to him? With a SQL statement that would look something like:

SELECT * FROM Customers Where verified = 0;

Throw this SQL to the database, and get all the results...

Then for each result, throw the information in the form, and once the supervisor has verified (click submit) update the field verified in the database.

I hope this helps...
heshan
Forum Commoner
Posts: 26
Joined: Tue Jul 13, 2010 1:16 pm

Re: Display data taken from a database in another form

Post by heshan »

Hi,

@novito, thanks for your ideas,

All the details of the customer should go through a supervisor. If he needs to do a modification he should be able to do it. Otherwise he should be able to view the details and approved. This is a typical process of a bank...

Thanks,
Heshan.
Post Reply