Jump to content


Photo

How To Get Value From Database In Select Form


  • Please log in to reply
3 replies to this topic

#1 saqib389

saqib389
  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 10 July 2006 - 05:27 PM

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

<SELECT NAME="category">

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


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



#2 willfitch

willfitch
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts
  • LocationNew Hope, PA

Posted 10 July 2006 - 05:38 PM

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
Zend Certified Engineer (ZEND001989)
www.willfitch.com

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 10 July 2006 - 05:39 PM

If this is correct someone tell me ok.
<?

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>

<?}?>


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 willfitch

willfitch
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts
  • LocationNew Hope, PA

Posted 10 July 2006 - 05:42 PM

It would be redarrow, but I think he's having issues more on his SELECT statement.  Take a look at that structure.
Zend Certified Engineer (ZEND001989)
www.willfitch.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users