Jump to content


Photo

Neeed Help Please Help Me.!


  • Please log in to reply
4 replies to this topic

#1 saqib389

saqib389
  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 06 July 2006 - 07:26 PM

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


<?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




<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'







#2 Gast

Gast
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts
  • LocationSouth East England

Posted 06 July 2006 - 08:28 PM

The only thing I can see is that your UPDATE query doesnt have a WHERE clause. You need to update the record only with the ID passed through the URL.
OS and Internet Specs:
Windows XP (with SP2), 1680x1050, PHP 4, MySQL 3, Internet Explorer 6 &7 /FireFox 2.0/Opera 9.2

Tutorials:
Simple Introduction to AJAX and XMLHttpRequest
Creating Live Data with AJAX Making a Google Suggest like application

#3 saqib389

saqib389
  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 06 July 2006 - 08:36 PM

THX FOR replying

yes my update code is
$sql = "UPDATE test_table SET field_value = '$field_value' WHERE  field_id = '$field_id'";
its still not updating :( please help me

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 06 July 2006 - 08:39 PM

echo $sql;

see what not working ok.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 Gast

Gast
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts
  • LocationSouth East England

Posted 06 July 2006 - 08:40 PM

Yeah do that to see if it displays correctly...

Is this a MySQL database or some other kind? I am not familiar with the "db_exec" function...
OS and Internet Specs:
Windows XP (with SP2), 1680x1050, PHP 4, MySQL 3, Internet Explorer 6 &7 /FireFox 2.0/Opera 9.2

Tutorials:
Simple Introduction to AJAX and XMLHttpRequest
Creating Live Data with AJAX Making a Google Suggest like application




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users