You are here: Re: [PHP] db insert question « PHP « IT news, forums, messages
Re: [PHP] db insert question

Posted by James Benson on 07/21/05 18:02

Thanks for all your help, ive got it working as i needed, my db query is
built like this, works but probably not the best way of doing it:-



$sqlStart = "INSERT INTO `tester` (";
$sqlMiddle = ") VALUES (";
$sqlEnd = ")";

$keys = array();
$values = array();


foreach($formData as $keyName => $keyValue){
array_push($keys, "`$keyName`");
array_push($values, "'$keyValue'");
}


$keys = implode(",", $keys);
$values = implode(",", $values);


$query = "$sqlStart$keys$sqlMiddle$values$sqlEnd";
$result = mysql_query($query);

 

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

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