Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   Form submission and MySQL retrieval (http://www.go4expert.com/forums/form-submission-mysql-retrieval-t20613/)

Paxfia 7Jan2010 06:40

Form submission and MySQL retrieval
 
Hi all,

I'm running on a limited knowledge of PHP, but I've been able to use intuition to get by up till now... I've got a problem, and I can't figure out the solution.

I managed to create a dynamic dropdown menu that populates itself with names from a MySQL table, with the option values being the IDs on the table. Using $_POST, the form sends the option value to another PHP page to execute the action.

I've confirmed that the action page IS receiving the proper ID number.

What I want to do is use PHP and the ID to retrieve the rest of the information relevant to that ID from the table and display it. (i.e., if I selected name#2, who's option value is 2, I want the action page to retrieve and display the rest of that entry (like phone number, email, etc.)

I have a feeling it's probably a fairly simple solution, I've just run out of ideas.:o

Help? Please and thank you :)

gotroot 29May2010 00:43

Re: Form submission and MySQL retrieval
 
whats the code?
if u can post the mysql and php, i can probably help you

ManzZup 7Aug2010 10:10

Re: Form submission and MySQL retrieval
 
yah displaying the code would help and meanwhile i think you tried using 'select from' and having some errors?

johnny.dacu 9Aug2010 22:11

Re: Form submission and MySQL retrieval
 
in your action page perform a select query base on the provided id.

raanrater 10Aug2010 16:34

Re: Form submission and MySQL retrieval
 
hi..

can send me a code of forums in PHP...??? meet again.

:baby:

ManzZup 10Aug2010 16:47

Re: Form submission and MySQL retrieval
 
:S code of forums?

pein87 15Aug2010 03:27

Re: Form submission and MySQL retrieval
 
You need to do

PHP Code:

$id$_POST['id'];
if(
is_numeric($id)) // check that its a real number
{
$q "SELECT * FROM table_name WHERE id=$id"//since its a number no need to add '".."'
if(mysql_num_rows($q) < 1// check if theres any results returned
{
//trigger no results error
echo " sorry but that id does not exist";
}
else
{
while(
$get_all_info mysql_fetch_assoc($q))
{
$ID $get_all_info[id];
$INFO $get_all_info[info];

}


the $get_all_info is returned as an associative array with the columns of the table as the array index.


All times are GMT +5.5. The time now is 11:55.