How Can I Retrive Value From Database In Select Form ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
saqib389
Forum Commoner
Posts: 44
Joined: Wed Nov 30, 2005 2:13 am

How Can I Retrive Value From Database In Select Form ?

Post by saqib389 »

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

Code: Select all

<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
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

Code: Select all

// Here are some examples:

// Selects Column1 and 2 from database where column2=$variable
$query = mysql_query("SELECT `column1`,`column2` FROM `database` WHERE `column2`='{$variable}' ");
// Selects every column from database where column2=$variable
$query = mysql_query("SELECT *` FROM `database` WHERE `column2`='{$variable}' ");
// Selects everything from databsae
$query = mysql_query("SELECT * FROM `database` ");

// Note: you have to use `` and not ' ' around columns or you can just leave them out.
You really need to check out google and PHP.net first!
Post Reply