Page 1 of 1

HTML-select Option and sql, php[SOLVE]

Posted: Thu Jun 07, 2012 10:50 pm
by jayson.ph
Hi all,

i have a html code

Code: Select all

Item Category:<select name = "txt_i_cat_name" style = " width:254px; height:23px;float:right;"/><option>?</option></select></div>
to determine category. and now how to show a file category from database into code above or under option?

Please help

Re: HTML-select Option and sql, php

Posted: Fri Jun 08, 2012 4:08 am
by social_experiment
jayson.ph wrote:and now how to show a file category from database into code above or under option?
Do you want to display a value from the database between the option tags? If so you would need a function that retrieves the value from the database; if you can give a bit more details it would help in solving the problem

Re: HTML-select Option and sql, php

Posted: Fri Jun 08, 2012 10:25 am
by jayson.ph
Hi guys.

i have here:

Code: Select all

Item Name: <?php include "../config/jph-config.php";
$query = "SELECT product_name FROM tbl_product";
	$result = mysql_query($query);
	
	echo "<select name = 'sel_nam' value = '' style = 'width:253px; height:23px;float:right;'></option>";
		while($_r = mysql_fetch_array($result))
		{
		echo "<option value = $_r[product_name]> $_r[product_name]</option>";
		}
		echo "</select>";?>
and its work fined. and now i need another way if there is?

Re: HTML-select Option and sql, php

Posted: Fri Jun 08, 2012 10:31 am
by Celauran
If that's working fine, why do you need another way?

Re: HTML-select Option and sql, php

Posted: Fri Jun 08, 2012 11:01 am
by jayson.ph
ah.. okay sorry never mind on this i take it as solve.

thanks

Re: HTML-select Option and sql, php[SOLVE]

Posted: Fri Jun 08, 2012 11:11 am
by Celauran
Not really what I meant. There may be perfectly valid reasons to want to do it differently, but if we don't know what those are or why you want to change it, it's going to be difficult for us to make suggestions.