Dropdown combo
5 posts
Page 1 of 1
Hello can anyone help me please i use the following code to display my table in the drop down box when i select a name how can i get it to show the rest of the record for that person?
PHP Code:
Mark
PHP Code:
Code: Select all
Thanks<select name="select">
<option id="0">---------- SELECT YOUR CUSTOMER NAME ----------</option>
<?php
require("db.php");
$getallCustomers = mysql_query("SELECT * FROM customers");
while($viewallCustomers = mysql_fetch_array($getallCustomers)){
?>
<option id="<?php echo $viewallCustomers['name_id']; ?>"><?php echo $viewallCustomers['name'] ?></option>
<?php } ?>
</select>
Mark
Hey,
you would want to change id="" of each option to value="" and then process it just as any regular form.
KR,
-Filip
you would want to change id="" of each option to value="" and then process it just as any regular form.
KR,
-Filip
CodenStuff wrote:Nope, it's just your sick and dirty mind. You sick twisted warped little pervo![]()
Hello,
Mark asked me to do a sample code in PM, so here it is, so everyone can see it:
And then, on submit.php or whatever you call it, following should be done:
-Filip
Mark asked me to do a sample code in PM, so here it is, so everyone can see it:
Code: Select all
<form action="where/to/submit.php" method="get">
<select name="select">
<option value="0">---------- SELECT YOUR CUSTOMER NAME ----------</option>
<?php
require("db.php");
$getallCustomers = mysql_query("SELECT * FROM customers");
while($viewallCustomers = mysql_fetch_array($getallCustomers)){
?>
<option value="<?php echo $viewallCustomers['name_id']; ?>"><?php echo $viewallCustomers['name'] ?></option>
<?php } ?>
</select>
<input type="submit" value="Show records" />
</form>
And then, on submit.php or whatever you call it, following should be done:
Code: Select all
KR,<?php
$customer_id = (isset($_GET['select'])) ? $_GET['select'] : die('No customer id selected');
// do something with $customer_id
-Filip
CodenStuff wrote:Nope, it's just your sick and dirty mind. You sick twisted warped little pervo![]()
Hi,
Thanks all i really wanted to do is make a table called customers with field name id and full name and address
in the dropdown box i want to display the persons full name and when i select a name from the drop down box it then shows me the information for that persons name from the database?
Thanks all i really wanted to do is make a table called customers with field name id and full name and address
in the dropdown box i want to display the persons full name and when i select a name from the drop down box it then shows me the information for that persons name from the database?
And that's what should be done by submit.php.. It will obtain the id selected from dropdown and based on that, it should use $customer_id to query the database. The query should be something like
Also I don't understand if you're trying to load customer data asynchronously using AJAX?
KR,
-Filip
Code: Select all
After you run that query, displaying record shouldn't be that hard and I'm sure you've done it before.SELECT * FROM customers WHERE id=$customer_id
Also I don't understand if you're trying to load customer data asynchronously using AJAX?
KR,
-Filip
CodenStuff wrote:Nope, it's just your sick and dirty mind. You sick twisted warped little pervo![]()
5 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023