Jump to content

Problem with php search code


kpetsche20

Recommended Posts

Everytime I execute the code below even when a result is in the database it only displays it works.

 

<?

if(isset($_POST['Submit']))

{

$searchsql = "SELECT * FROM tblpeople";

$searchquery = mysql_query($searchsql);

while($data = mysql_fetch_array($searchquery))

{

$search = $data['tblpeople'];}

if($data['tblpeople'] != $_POST['search'])

{  echo "works"; }

else { "doesn't work";}

}

 

?>

Link to comment
https://forums.phpfreaks.com/topic/113258-problem-with-php-search-code/
Share on other sites

Try this...

 

<?php

if(isset($_POST['Submit']))
{
$searchsql = "SELECT * FROM tblpeople";
$searchquery = mysql_query($searchsql);
while($data = mysql_fetch_array($searchquery))
{
$search = $data['tblpeople'];}

if($data['tblpeople'] != $_POST['search'])
{  echo "works"; }
else { "doesn't work";}
}
}
?>

Doesn't work even when i typed in the correct info it gives me the same error as if it was incorrect..

 

 

 

Here's the new code

 

<?php

if(isset($_POST['Submit']))
{
$searchsql = "SELECT * FROM tblpeople";
$searchquery = mysql_query($searchsql);
while($data = mysql_fetch_array($searchquery))
{
$search = $data['tblpeople'];}

if($data['tblpeople'] != $_POST['search'])
{  echo "doesn't work"; }
else { "works";}
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.