Page 1 of 1

How Can I Retrive Value From Database In Select Form ?

Posted: Mon Jul 10, 2006 12:25 pm
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

Posted: Mon Jul 10, 2006 12:31 pm
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!