?
Solved

query returns no results

Posted on 2006-03-29
6
Medium Priority
?
276 Views
Last Modified: 2013-12-12
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'>";




?>
0
Comment
Question by:Karl01
6 Comments
 
LVL 33

Accepted Solution

by:
snoyes_jw earned 1500 total points
ID: 16326479
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>...";
0
 

Author Comment

by:Karl01
ID: 16326742
Thanks for the reply but tried that and messed about with a few thing still giving me a blank textarea! any other ideas?

cheers!
0
 
LVL 33

Expert Comment

by:snoyes_jw
ID: 16326874
checked to make sure there are results returned?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:Karl01
ID: 16327374
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!
0
 
LVL 3

Expert Comment

by:gileze33
ID: 16329796
Are you wanting to simply check whether any results have been returned, or are you trying to actually print the results?
0
 
LVL 8

Expert Comment

by:hiteshgupta1
ID: 16330979
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>
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month13 days, 12 hours left to enroll

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question