Jump to content

PHP/MYSQL - Storing Results Not Found


tomtimms

Recommended Posts

I am trying to do a search to my MYSQL DB and having an issue displaying the results that were not found in my query.  I have a table full of names and I am doing a search against it to find the names that are found and not found.  I want to return all the names that were found in one list then all the names that were not found in another list.  This is what I have so far, I am able to return all the names that were found but a little confused when it comes to displaying the ones that were not.

 

$trimmed_up = explode(",", $trimmed);

 

$query = "select * from site_keywords WHERE keyword IN('" . join("','", $trimmed_up) ."') ORDER BY id";

 

$result = mysql_query($query) or die("Couldn't execute query");

 

 

// begin to show results set

 

$count = 1 + $s;

 

 

while ($row = mysql_fetch_array($result)) {

    $title = $row["name"];

 

    echo "$title<br/>";

    $count++;

}

 

 

Link to comment
https://forums.phpfreaks.com/topic/196984-phpmysql-storing-results-not-found/
Share on other sites

hummm...

 

I take it you are using $_POST to search for users....

 

I would compare the post with the results from database...

 

Take away those that match leaving you to echo those that are not...

 

if($_POST != $array)

{

//show name

}

 

and stick that in a loop

<form id="htmlForm" action="feed_search_submit.php" method="get">

 

  <input type="text" name="q" />

  <input type="submit" name="Submit" value="Search" /> *(multiple search seperate with a comma)

</form>

 

 

then my php file

 

$var = @$_GET['q'];

$trimmed = trim($var);

 

 

 

 

I am reopening this as I am still having issues.  I decided to do a comparision between my search input and the results from my query.  So i did

 

function getCompare($trimmed_up) {

   

    $query = "select * from site_keywords WHERE keyword IN('" . join("','", $trimmed_up) ."') AND status ='1' AND sid ='3' ORDER BY id";

    $results = mysql_query($query);

   

    $array = mysql_fetch_assoc($results);

    return $array;

}

 

$all = getCompare($trimmed_up);

 

$array1 = $all;

$array2 = $trimmed_up;

$compare = array_diff($array2,$array1);

print_r($compare); 

 

however when I do a search for a keyword it shows up in both found and not found.  Anyone else know how to get the results of a query that were not found?

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.