You are here: Re: Php array's values insertion in mysql table « PHP Programming Language « IT news, forums, messages
Re: Php array's values insertion in mysql table

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]


Удаленная работа для программистов  •  Как заработать на 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

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