query returns no results

Hi i and trying to create an update function for my web site i have two scripts one to take the users input and a second to search for the valu and output the record in a text field for editing before a third script is used to updte the data, i am having trouble with the first 2 as the scripts run but there is nothing outputted in the textarea i have listed the code below, can anyone help?

<html>
<head><title>update</title></head>
<body>
<?php

 $searchterm = strip_tags(trim($_POST['searchterm']));

 $label_array = array (
                   "searchterm" => "Please enter your search term");

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

{

   echo "<p><hr>
      <form action='staff_update_results.php' method='POST'>
      <center>
      <table width='95%' border='0' cellspacing='0' cellpadding='2'>
      </tr>

      <tr><td align='right'><B>{$label_array['searchterm']}:</br></td>
        <td><input type='text' name='results' size='65' maxlength='65'> </td>
      </tr>
</table>
      <p><input type='submit' value='Run search'>
      </form>
      </center>";
}

   
?>
</body></html>

<?php

  include("connect.inc");
    $connection = mysql_connect($host,$user,$password)
       or die ("couldn't connect to server");
    $db = mysql_select_db($database,$connection)
       or die ("Couldn't select database");

$query = "SELECT * FROM staff WHERE lastname = '$_POST[searchterm]'";
$result = mysql_query($query)  or die(mysql_error());

$row = mysql_fetch_array($result,MYSQL_ASSOC);


$result = mysql_query($query) or die(mysql_error());

$row = mysql_fetch_array($result,MYSQL_ASSOC);

$label_array = array (
                  "searchresults" => "The search retured the results");

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

echo "<p><hr>
      <form action='staff_update.php' method='POST'>
      <center>
      <table width='80%' border='0' cellspacing='0' cellpadding='2'>
      </tr>

      <tr><td align='right'><B>{$label_array['searchresult']}:</br></td>
        <td><textarea name='searchresults' cols='40' rows='6'>

 </textarea> </td>
      </tr>

      <p><input type='submit' value='Go Back'>";




?>
Karl01Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

snoyes_jwCommented:
foreach ($_POST as $field => $value); <-- there's a semicolon that shouldn't be.

There's also nothing within the textarea tags.  You'll need to put something to do with $row in there.

echo "...<textarea>";
print_r($row);
echo "</textarea>...";

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Karl01Author Commented:
Thanks for the reply but tried that and messed about with a few thing still giving me a blank textarea! any other ideas?

cheers!
snoyes_jwCommented:
checked to make sure there are results returned?
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

Karl01Author Commented:
how do u mean? I have checked the query in the mysql prompt and the value I entered is in the table and does return a result!
gileze33Commented:
Are you wanting to simply check whether any results have been returned, or are you trying to actually print the results?
hiteshgupta1Commented:
Well,the problem is with the text area itself
u have put nothing between the opening and closing tags for Txt Area
<text area><?Put some value over here(output of the query?></Text Area>
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.