HTML-select Option and sql, php[SOLVE]

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
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

HTML-select Option and sql, php[SOLVE]

Post 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
Last edited by jayson.ph on Fri Jun 08, 2012 11:01 am, edited 1 time in total.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: HTML-select Option and sql, php

Post 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
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

Re: HTML-select Option and sql, php

Post 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?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: HTML-select Option and sql, php

Post by Celauran »

If that's working fine, why do you need another way?
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

Re: HTML-select Option and sql, php

Post by jayson.ph »

ah.. okay sorry never mind on this i take it as solve.

thanks
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

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

Post 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.
Post Reply