Jump to content

How To Get Value From Database In Select Form


saqib389

Recommended Posts

Hello
can any one tell me how can i retrive value from Database in SELECT form

[code]
<SELECT NAME="category">

WHAT WILL BE THE SQL STATEMENT AND HOW TO WRITE HERE TO GET CATEGORY FROM DATABASE
</SELECT>
[/code]


Database Tables Name and Field

pa_categories
    category_id
    category_name

pa_subcategory_category_map
      subcategory_id(parent category)
      category_id ( child category )

please tell me how can i get value in Select form from data base
thank you in advance
waiting for reply

Link to comment
Share on other sites

Your data structure is very confusing.  It's even more confusing since you didn't provide any details on it.  Lastly, this is phpfreaks.com, rather than mysqlfreaks.com.  With that, maybe this is what you are looking for:

SELECT
pa_categories.category_name AS category_name1,/* parent category */
pa_categories.cateogry_name AS category_name2 /* subcategory */
FROM pa_categories
LEFT JOIN pa_subcategory_category_map ON pa_categories.category_id=pa_subcategory_category_name.subcategory_id
Link to comment
Share on other sites

If this is correct someone tell me ok.
[code]
<?

database connection

$query="select * from whatever where what_ever=$what_ever":
$result=mysql_query($query);

while($record=mysql_fetch_assoc($result) {

?>


<form method="post" action="what_ever.php">

<select name="whatever">

<option value="<? echo $record['what_ever'];?>"><?echo $record['what_ever'];?></option>

</select>

<input type="submit" name="submit" value="send">

</form>

<?}?>

[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.