All pastes #279753 Raw Edit

Mine

public text v1 · immutable
·published 2006-12-15 08:53 UTC
rendered paste body
<?php
//PRIMA:

		if ($_POST['title_en'] OR $_POST['content_en']) {

			$db->query("UPDATE help_page SET name = '$_POST[name]' ,
title_en = '$_POST[title_en]' , content_en = '$_POST[content_en]' 
WHERE id = $id ");

		}

		if ($_POST['title_it'] OR $_POST['content_it']) {

			$db->query("UPDATE help_page SET name = '$_POST[name]' ,
title_it = '$_POST[title_it]' , content_it = '$_POST[content_it]' 
WHERE id = $id ");

		}

		if ($_POST['title_fr'] OR $_POST['content_fr']) {

			$db->query("UPDATE help_page SET name = '$_POST[name]' ,
title_fr = '$_POST[title_fr]' , content_fr = '$_POST[content_fr]' 
WHERE id = $id ");

		}

		if ($_POST['title_de'] OR $_POST['content_de']) {

			$db->query("UPDATE help_page SET name = '$_POST[name]' ,
title_de = '$_POST[title_de]' , content_de = '$_POST[content_de]' 
WHERE id = $id ");

		}

		if ($_POST['position'] OR $_POST['category']) {

			$db->query("UPDATE help_page SET name = '$_POST[name]' ,
position = '$_POST[position]' , category = '$_POST[category]' 
WHERE id = $id ");

		}

// DOPO:

		$validrows = array("name", "title_en", "title_it", "title_fr", "title_de", "content_en", "content_it", "content_fr", "content_de", "position", "category", "showpage");

		$query = "UPDATE help_page SET id = '$_POST[id]'";

		foreach ($_POST as $field => $value) {

			if (in_array($field, $validrows)) {

				if ($field != $id) { $query .= ", $field = '$value'"; }

			}

		}

		$query .= " WHERE id = '$_POST[id]'";

		$db->query("$query");