Reply to Re: converting numerical values to char

Your name:

Reply:


Posted by J.O. Aho on 12/19/06 13:45

Joja wrote:
> Hi !
>
> Maybe i have described this on the wrong way....
>
> This is what im passing after you click update button:
>
> <select name="options">
> <option value="0" >Snow </option>
> <option value="1" >Winter</option>
> </select>
>
> If i write this to db then i will write "0" or "1" and i want to store
> "Snow" or "Winter" into db.
> I have to use numerical values for my other use with select, but i must
> store text into db.

Why not make a table with the following:

table MiscStuff
MSID INT
MSName

and you store things like

0 Snow
1 Winter

You store the values into the database, when you fetch you just join the
MiscStuff table with the table where you store the data, this way you get the
text out of the database.


> So i can make something like this:
> if (options = "0" )
> options = "Snow";
> write options into db.

You better do it like this:
switch($_REQUEST['options']) {
case 0:
$options = "Snow";
break;
case 1:
$options = "Winter";
break;
default:
/* Value was selected that isn't listed before this line */
$options = "Stupid user";
break;
}

Or why not just

<select name="options">
<option>Snow</option>
<option>Winter</option>
</select>


--

//Aho

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация