Ask Experts Questions for FREE Help!
 

Free Answers in 3 Easy Steps

Register Now
3 Steps
 


Ask QuestionsprogressAnswer QuestionsprogressBuild ReputationprogressBecome an Expert
 
At Ask Me Help Desk you can ask questions in any topic and have them answered for free by our experts. To ask questions or participate in answering them you must register for a free account. By registering you will be able to:
  • Get free answers from experts in any of our 300+ topics.
  • Accept money for answers that you provide.
  • Communicate privately with other members (PM).
  • See fewer ads.
  View Answers    Answer this question    Ask a question  
 

jayavani
Mar 19, 2011, 11:16 AM
Hai......someone *** help me.......
Food_ID:
Food_id :
Food_Name :
Above is my interface...for the 1st food_ID I'm using drop down button...so now I want when I click drop down button it should fetch food_id from DB...ten when I select one ID...I wan the information about that ID show in 2nd food_id text field and the food name should appear in food_name text field......*** help.......

Below I attach my code.....
**************************************'
<?php
Include 'include/opendb.php';
Require_once("models/config.php");

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-'
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>add new</title>
</head>

<body>

<div align="center">WELCOME TO AMIGO WIRELESS RESTAURANT SYSTEM</div>
<p align="center"> FOOD</p>
<p align="center"><label>
<div align="left">
<p><strong>Food_ID: </strong>
<select name="menu" id="menu">
<?php

$result = mysql_query('SELECT food_id , food_name FROM food') or exit(mysql_error());

While ($row = mysql_fetch_assoc($result))
{


Echo '<option value="' . $row['food_id'] . '">' . $row['food_id'] . '</option>';


}
Echo '</select>';

?>
</select>
<p>Food_id :
<input type="text" name="id" id="id" />

<p>
<p>Food_Name :
<input type="text" name="name" id="name" value="" />
<p>F

<form id="form1" name="form1" method="post" action="">
<div align="center">
<input type="submit" name="update" id="update" value="new" />
<input type="submit" name="edit" id="edit" value="edit" />
<input type="reset" name="clear" id="clear" value="clear" />
<input type="submit" name="delete" id="delete" value="delete" />
</div>
</form>
<p align="center"> </p>
</body>
</html>
**************************************'
With above code I'm able to see food_ID in drop down button but I don't know how to pass that to text field.........

Thanking in advance.....

rlerne
Oct 22, 2011, 10:31 PM
I'm finding it sort of hard to read your question, so hopefully I have this right.

I'm thinking you want your drop down to show the food name, not the food ID number, correct?

Easy solution. Here's the line you have:

Echo '<option value="' . $row['food_id'] . '">' . $row['food_id'] . '</option>';


Change it to this:

Echo '<option value="' . $row['food_id'] . '">' . $row['food_name'] . '</option>';

rlerne
Oct 22, 2011, 10:33 PM
^Apologies for the broken formatting. I assumed this box would encode entities... Anyway, corrected reply:

I'm finding it sort of hard to read your question, so hopefully I have this right.

I'm thinking you want your drop down to show the food name, not the food ID number, correct?

Easy solution. Here's the line you have:


Echo '&lt;option value="' . $row['food_id'] . '"&gt;' . $row['food_id'] . '&lt;/option&gt;';

Change it to this:

Echo '&lt;option value="' . $row['food_id'] . '"&gt;' . $row['food_name'] . '&lt;/option&gt;';