How do i write php code for getting field from mysql as dropdown in php, and, also to display the related records of selected option in dropdown from database
My question
0
Light Poster
Recommended Answers
Jump to Post$query = "SELECT `id`, `name` FROM `tableName`"; $result = mysql_query($query) or die(mysql_error()."[".$query."]"); <select name="dropdown"> <?php while ($row = mysql_fetch_array($result)) { echo "<option value=".$row['id']."'>".$row['id'] . " - " . $row['name']."</option>"; } ?> </select>
Jump to PostYou need to use jquery/ajax so when you select an option from the dropdown to filters on this information
Jump to Post$.ajax({ url: 'link_to_url', type: 'post', data: {}, success: function (data) { //update dom here } });
All 12 Replies
jKidz
0
Junior Poster in Training
My question
0
Light Poster
iamthwee
My question
0
Light Poster
iamthwee
mark.giles.14
0
Light Poster
mattskills
0
Newbie Poster
My question
0
Light Poster
mattskills
0
Newbie Poster
My question
0
Light Poster
My question
0
Light Poster
fireburner29
0
prabaweb
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.