Click here to Skip to main content
15,918,516 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
//connecting to the database and running query

$get_list_sql="SELECT id, CONCAT_WS(',', l_name, f_name) AS display_name FROM 
$get_list_res=  mysqli_query($dbc, $get_list_sql);

<!--Building of drop down menu start from here-->

<form action="post.php" method="post">
    <select name="sel_id">
       <option value="">--Select One--</option> 
<!--Starting while loop for fetching the array-->
<option value="<?php $x['id']?>" name="<?php $x['id']?>"><?php echo $x['display_name']?></option>
    <input type="submit" value="submit"/>
<!--Till here every thing work fine-->


// this portion is not working what i want to do its to get the id, because if 
//I can get the id, i can run the query and get the result which i want to get
// from this table
    $safe_id = mysqli_real_escape_string($mysqli, $_POST['sel_id']);
    echo $safe_id;

It's like telephone directory, in drop down menu, its show the people who are in the data table.
what i want to do is to select the people from drop down menu and when i click on the submit button, it should show me the result for that particular person

[edit]SHOUTING removed - OriginalGriff[/edit]
Updated 9-Nov-13 20:00pm
OriginalGriff 10-Nov-13 2:00am    
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalisation if you want to be taken seriously.
arifsuhail123 10-Nov-13 2:09am    
and you think that's the solution to my problem?
OriginalGriff 10-Nov-13 2:30am    
No, I think you were being rude and as a result I'm not inclined to even look at your problem.
arifsuhail123 10-Nov-13 3:36am    
thanks for not looking.
OriginalGriff 10-Nov-13 3:45am    
You're welcome!
If you want me to not look again, feel free to start off by shouting at me...

1 solution

In addition to my previous suggestion, I spotted 2 more mistakes:
1). no need name attribute in the option tag
2). must add echo to the value attribute in the option tag.

<!-- <option value="<?php $x['id']?>" name="<?php $x['id']?>"><?php echo $x['display_name']?></option> -->
<option value="<?php echo $x['id']?>"><?php echo $x['display_name']?></option>

To convince myself, I made a similar mockup and tested it on my machine, it should work fine now.

Good luck.
Share this answer
arifsuhail123 10-Nov-13 13:59pm    
Thanks you help me alot, i wasted almost two trying to figure it out,

thanks for help
arifsuhail123 10-Nov-13 14:04pm    
sorry i am commenting again, cause i made a mistake in the last message, i tried to say that i wasted two days before posting it, and you solved it for me in few hours thank you very,much.

and if your looking for mistake in my last message, mistake is i forget to right 'Days' after 'two'
Peter Leow 10-Nov-13 20:52pm    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900