All right I need a hint 🙂
What do I use in the select query to match the listed words to the ones in the db?
<?
// Display the words in the file
// This part works except it shows unacceptable words (like tags) as a blank line
$contents = file("itinerary7.php");
$updateCode=implode("\n",$contents);
$update=preg_replace('#<([^>]|\n)*>#is', '',$updateCode);
$update=explode(" ",$update);
// Loop through the array, show word number and words.
foreach ($update as $word_num => $word) {
echo "Word #<b>{$word_num}</b> : " . $word . "<br />\n";
}
echo "<hr>";
// End of display and working part
// Query the db for matching words
// This part doesn't work yet
// If the next line is uncommented then we get working results.
// The problem I have is I don't know what to use in the query for '$word'.
$word = "Yellowstone";
mysql_select_db("yellowstone");
$words_qry = "SELECT * FROM words WHERE word = '$word'";
$words_result = mysql_query($words_qry);
$num_results = mysql_num_rows($words_result);
if ($num_results == 0)
{
echo "Sorry, no matches.<br>";
// exit;
}
// Start Output
echo "<p>Number of words found: ".$num_results."<br>";
for ($i=0; $i <$num_results; $i++)
{
$link = str_replace($word, mysql_result($words_result,$i,"link"), $word);
echo "".($i+1).". ";
echo $link;
echo "<br>";
}
echo "<hr>";
?>
If I comment out the $word = "Yellowstone"; line then I get a reply of Sorry, no matches. If I uncomment it then the querry works fine but only for that word.
Thanks again,
Jeff