Page 1 of 1

NEED HELP PLEASEEE

Posted: Thu Jul 06, 2006 2:18 pm
by saqib389
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello all
i just want to ask from you is that.. i want to update my data.. i can add it.. but if i click on the numbers and i want to update that which i just enter it.. then can any one tell me how to do it ? coz i m unable to add update query

here is the link of my work
http://saqib.flowlabs.com/database/
here is the code of CONTROL FILE

Code: Select all

<?php
function saqib_db_test () {
	$config = get_config_array($_SERVER["client_name"], 'saqib.db_test');
	$notice_array = array();

	//select all data
	if ($_REQUEST["mode"] == "") {
		$sql = "SELECT field_id, field_value FROM test_table ORDER BY lower(field_value)";
		$result = db_exec($_SERVER["client_name"], $sql);
		if ($result["success"] != true) {
			return $result;
		}
		$numrows = pg_numrows($result["result"]);
		$design_process = 'start';

	//add one record
	} elseif ($_REQUEST["mode"] == "add") {
		if ($_REQUEST["step"] == 2) {
			$result = validate_field ($_REQUEST["field_value"], 'Field Value', true, false, 200, 10, -1);
			if ($result["success"] != true) {
				$notice_array[] = $result["notice"];
			}
			if (sizeof($notice_array) > 0) {
				$design_process = 'add';
			} else {
				$sql = "INSERT INTO test_table (field_value) VALUES (" . db_esc($_REQUEST["field_value"]) . ")";
				$result = db_exec($_SERVER["client_name"], $sql);
				if ($result["success"] != true) {
					return $result;
				}
				$design_process = 'added';
			}
		} else {
			$design_process = 'add';
		}

	//edit one record
	} elseif ($_REQUEST["mode"] == "edit") {
		if ($_REQUEST["step"] == 3) {
			$result = validate_field ($_REQUEST["field_value"], 'Field Value', true, false, 200, 10, -1);
			if ($result["success"] != true) {
				$notice_array[] = $result["notice"];
			}
			$result = validate_field ($_REQUEST["field_id"], 'Field Id', true, true);
			if ($result["success"] != true) {
				$notice_array[] = $result["notice"];
			}

			if (sizeof($notice_array) < 1) {




[color=red][b]$sql = "UPDATE test_table SET field_value = '$field_value' ";[/b][/color]

			
				$result = db_exec($_SERVER["client_name"], $sql);
				if ($result["success"] != true) {
					return $result;
				}
				$design_process = 'edited';
			} else {
				$design_process = 'edit';
			}
		} else {
			$design_process = 'edit';
		}

	} else {
		$design_process = 'error';
	}

	$buffer = get_design_buffer('saqib.db_test', $design_process, get_defined_vars());

	return array("success" => true, "buffer" => $buffer);
}
?>
here is the code of EDIT FILE

Code: Select all

<html>
<head>
<title>saqib.db_test</title>
</head>
<body>

<div style="margin:100px">


<?php


if (sizeof($notice_array)  < 1) {
	echo('<pre>');
	print_r($notice_array);
	echo('</pre><br /><br />');
}


?>


<form method="post" action="/database/">

<input type="hidden" name="mode" value="edit" />
<input type="hidden" name="step" value="3" />




Field Value: <br /><input type="text" name="field_value" />
<br />

<input type="submit" value=" Edit Now!" />

</form>

</div>

</body>
</html>

PLEASE ANY ONE CAN HELP ME ... I NEED THE SOLOUTION'


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]2.[/b] Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.[/quote]

Posted: Fri Jul 07, 2006 9:15 am
by poizn
I fiddled around with your page and it seems to work fine (update and add)

Try elaborate on the problem more.

:)