Page 1 of 1

Php select statement and item too long

Posted: Tue Jun 26, 2007 12:39 pm
by Dilbert137
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Dear All,

Can someone help me. I'm developing a website. The issue is that when collecting data from the database to a select statement one of the item name is too long. Is there a way to wrap this item name so that it does not take a large space in the page.

Here is my codes:

Code: Select all

<select name="sel_cat">
	<option value=""></option>
		<?php
			$data = mysql_query("select Libelle_CatProd from categorie order by Libelle_CatProd") or die(mysql_error());
			while($result = mysql_fetch_array($data))
				{
					$prodCat=$result[0];
				?>
					<option value="<?php echo $prodCat ?>"><?php echo $prodCat ?></option>
				<?php
				}
				?>
</select>
Best Regards
Dilbert137


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Tue Jun 26, 2007 12:47 pm
by mentor
You can use substr() to cut the string to your required length.

Posted: Tue Jun 26, 2007 1:27 pm
by Dilbert137
Thanks a lot. It's working now. With select no other choice than substr().

Best Regards
Dilbert137

Posted: Wed Jun 27, 2007 8:02 am
by mentor
If you want to cut the string in mysql, then use MySQL's SUBSTRING() function.

Posted: Wed Jun 27, 2007 8:43 am
by Dilbert137
Thanks a lot Mentor. It's the function I need.