I am trying to write a query that gets the name of every 
personr who has a neme:  $neve
This parameter come from a form like this:

FORM ACTION="sqlphp.php" METHOD="post"> 
   <input type="text" name="neve" size="40">
   <input type="submit" value="Dend data">
</FORM>
</pre>

The following script is running, but if I write in the 7-th row:

$result = mysql_query("SELECT * FROM employees WHERE first = $neve",$db)

It is wrong...
(I want to replace the "if" statement in the 21-th row.)

Can anyone help?


<html>
<body>
<?php

$db = mysql_connect("localhost", "root");
mysql_select_db("mydb",$db);
$result = mysql_query("SELECT * FROM employees",$db)
   or die ("Not valid request");

$rows = mysql_num_rows($result);
echo "Whole number of rows:.$rows<br>";

echo "<table border=1>\n";
echo "<tr><td><b>Name</td><td><b>Address</tr><td><b>Position</tr>";

// $i=0;
// while ($myrow = mysql_fetch_array($result))

for ($i = 0; $i <=$rows - 1; $i++) 
{
  if (mysql_result($result,$i,"first")  == $neve){
  printf("<tr><td>%s %s</td><td>%s</td><td>%s</td></tr>\n",
        mysql_result($result,$i,"first"),
        mysql_result($result,$i,"last"),
        mysql_result($result,$i,"address"),
        mysql_result($result,$i,"position"));
    }
// $i++;
}
echo "</table>\n";
mysql_free_result ($result);

?>
</body>
</html>

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to