extracting id from db from a form field

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello everyone,

I need a little help. I've never tried to extract from a db in the
manner I'm trying. It's pretty simple and straightforward I believe, but
for some reason I can't figure out how.

What I have is a form with 1 simple field, and this field takes the ID
of the row I want returned.

Here's my code so far. 

--index.php--

echo '<form action="result.php" method="post">
Enter Error Code:<br />
<input type="text" name="ErrorCode" /><br />
<input type="Submit" name="submit" value="Submit">
</form>' ;

-result.php-
$errorcode = $_POST['ErrorCode'];

echo $errorcode;

$sql = mysql_query("SELECT errorcode,definition FROM Sheet1");

while ($row = mysql_fetch_array($sql)) {
	echo "$row[errorcode]<br />";
	echo "$row[definition]<br />";
} 

So far this is as far as I've got. I can successfully post the number
entered into the form field, but I'm having trouble making use of the
number.

With this code, my idea was to turn the posted number from the form into
a variable and use that as a reference to extract that row number from
the db, but my attempts are unsuccessful.

I've also unsuccessfully attempted to use a WHERE clause in my SELECT to
only display the row that is posted.

I hope all this makes sense.

Regards,
David M.




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux