Forum Moderators: coopster
This is a basic idea I suppose of what I want to do it "sort" of works.
Code:
<?php
$dbHost = 'localhost';
$dbUser = 'spaztast';
$dbPass = '-----------;
$dbName = 'spaztast_spazweb';
mysql_connect($dbHost,$dbUser,$dbPass);
mysql_select_db($dbName);
$var = "book programming";
$var2 = explode(" ", $var);
$result = mysql_query("SELECT * from tbl_keyword");
$i = 0;
while($r = mysql_fetch_array($result))
{
if($var2[$i] == $r['k_word'])
{
echo "Key Exist's";
}
else{
echo $r['k_word'] . "<br>";
}
$i = $i++;
}
?>
Now heres the thing the table looks like this:
Code:
+---------+-------------+-------+
¦ word_id ¦ k_word ¦ pd_id ¦
+---------+-------------+-------+
¦ 1 ¦ palm ¦ 11 ¦
¦ 2 ¦ programming ¦ 17 ¦
¦ 3 ¦ C# ¦ 18 ¦
¦ 4 ¦ book ¦ 18 ¦
+---------+-------------+-------+
This is the output when the script is run:
palm
programming
C#
Key Exist's <-- Would have been "book".
I guess what I am asking is, how I loop one exploded value against all the keys in the database? I think thats what I want too do just unsure of how to do it.