Re: extracting id from db from a form field

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

 



On Fri, 2011-05-27 at 14:48 -0500, Karl DeSaulniers wrote:
> Hi David,
> Try this..
> 
> if(!isset($_POST['ErrorCode'])) {
> 	die('You did not enter an error code!');
> } else {
> 	$errorcode = $_POST['ErrorCode'];
> 	$sql = mysql_query("SELECT * FROM Sheet1 WHERE errorcode='". 
> $errorcode."' ");
> 	if($sql && mysql_numrows($sql) > 0) {
> 		$row = mysql_fetch_array($sql);
> 		for($i=0; $i<mysql_numrows($sql); $i++) {
> 			echo ("Error Code: ".$row[$i]['errorcode']."<br />");
> 			echo ("Error Definition: ".$row[$i]['definition']."<br />");
> 			echo ("<br />");
> 		}
> 	} else {
> 		die('No Error Code found in database');
> 	}
> }
> 
> Have not tested this, and there may be a better "short-hand" way of  
> writing this, but hope it gets you on your way...

Thank you Karl, after a minute or two, or three ;-) I had it working,
but I had to change in the first line !isset to empty. For some reason
it wasn't working with !isset. and I had to
change: .$row[$i]['errorcode']. to .$row['errorcode']. because it wasn't
allowing for more than 1 digit in the error code number, but it was
displaying the correct error definition
and
 .$row[$i]['definition']. to .$row['definition']. had to be changed
because it was displaying the error code and not the definition.

Now the only problem I've got to figure out is altering it so it doesn't
exclude row[0].

Blessings,
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