Jump to content

Archived

This topic is now archived and is closed to further replies.

saqib389

How To Get Value From Database In Select Form

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

Share this post


Link to post
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

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites
It would be redarrow, but I think he's having issues more on his SELECT statement.  Take a look at that structure.

Share this post


Link to post
Share on other sites

×

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.