Karl01
asked on
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['se archterm'] ));
$label_array = array (
"searchterm" => "Please enter your search term");
foreach ($_POST as $field => $value);
{
echo "<p><hr>
<form action='staff_update_resul ts.php' method='POST'>
<center>
<table width='95%' border='0' cellspacing='0' cellpadding='2'>
</tr>
<tr><td align='right'><B>{$label_a rray['sear chterm']}: </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, $connectio n)
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_ASSO C);
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSO C);
$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_a rray['sear chresult'] }:</br></t d>
<td><textarea name='searchresults' cols='40' rows='6'>
</textarea> </td>
</tr>
<p><input type='submit' value='Go Back'>";
?>
<html>
<head><title>update</title
<body>
<?php
$searchterm = strip_tags(trim($_POST['se
$label_array = array (
"searchterm" => "Please enter your search term");
foreach ($_POST as $field => $value);
{
echo "<p><hr>
<form action='staff_update_resul
<center>
<table width='95%' border='0' cellspacing='0' cellpadding='2'>
</tr>
<tr><td align='right'><B>{$label_a
<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,
or die ("couldn't connect to server");
$db = mysql_select_db($database,
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,
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result,
$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_a
<td><textarea name='searchresults' cols='40' rows='6'>
</textarea> </td>
</tr>
<p><input type='submit' value='Go Back'>";
?>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
checked to make sure there are results returned?
ASKER
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!
Are you wanting to simply check whether any results have been returned, or are you trying to actually print the results?
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>
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>
ASKER
cheers!