[PHP/SQL] Data from multiple rows in one table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

timvw wrote:Since you've discovered the joy of using sprintf: http://www.timvw.be/elegantly-generate-sql-queries/
Thanks timvw :)
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

Post by thiscatis »

i did it like this,
may not be the most elegant solution, but does the trick

Code: Select all

if($_POST['submit']) {
		
		$arr = array();
		array_push($arr, $_POST['sitename']);
		array_push($arr, $_POST['siteurl']);
		array_push($arr, $_POST['siteowner']);
		array_push($arr, $_POST['rootemail']);
		array_push($arr, $_POST['rootpass']);
		array_push($arr, $_POST['licensetype']);
		array_push($arr, $_POST['rootadress']);
		array_push($arr, $_POST['rootzip']);
		array_push($arr, $_POST['rootcity']);
		array_push($arr, $_POST['rootphone']);
		array_push($arr, $_POST['rootpaypal']);
		array_push($arr, $_POST['rootbankwire']);
		array_push($arr, $_POST['rootcountry']);
		array_push($arr, $_POST['rootbankname']);
		array_push($arr, $_POST['rootbankiban']);
		array_push($arr, $_POST['rootbankswift']);
		
		for ($i = 1; $i <= count($arr)  ; $i++){
			mysql_query("UPDATE cms_settings SET value='".$arr[$i-1]."' WHERE setting_id=".$i ) or die(mysql_error());
   }
Post Reply