|
Posted by sathyashrayan on 12/20/07 05:45
On Dec 18, 8:23 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
> On Tue, 18 Dec 2007 07:15:46 +0100, sathyashrayan <asm_f...@yahoo.co.uk>
> wrote:
>
>
>
> > Dear group,
> > I have this following problem.. In one javascript I get dynamic text
> > boxes, that is <input type='text'> will be created different id and
> > name with each click on a button. And the form is able to transfer
> > those values to the submitting page with each text box name as key and
> > its value as array value. I want those values to be inserted in the
> > mysql database with insert query. I just want to insert the one
> > specified field in the mysql table.
>
> > Two approaches I found..
>
> > One is using the [] array in the text box name. With the help of
> > serialize I can insert those sterilized arrays. But I am going to use
> > those dynamic values as parent level menus, with the self referential
> > database tables.. something like the typo3 CMS menus.
>
> > Second one is the following little code which I got stuck for 3
> > days.. Please help..
>
> > Code:
> > --------
>
> > include "../db/config.php";
>
> > $mainMenus = $_POST;
>
> > function Insert($table,$values)
> > {
> > foreach($values as $val)
> > {
> > $q = "INSERT INTO ".$table. " ( MenuName ) VALUES ( ". $val ." )
> > ";
>
> $val = mysql_real_escape_string($val);
> $q = "INSERT INTO ".$table. " ( MenuName ) VALUES ( '". $val ."' )";
>
> _always_ escape string data, always quote strings.
> --
> Rik Wasmus
Thanks a lot for all your helps.. I got the problem solved with
include "../db/t_config.php";
$mainMenus = $_POST;
$query = "INSERT INTO menus( MenuName ) VALUES ('".join("'),('",
$mainMenus )."')";
mysql_query($query) or die(mysql_error());
echo '<br>';
Sorry for late reply..
Navigation:
[Reply to this message]
|