Guest Posted July 19, 2008 Share Posted July 19, 2008 I have a mysql select statement that looks like this: $searchQuery = "SELECT title, content FROM pages WHERE title LIKE '%$searchString%' OR content LIKE '%$searchString%' UNION (SELECT title, content FROM posts WHERE title LIKE '%$searchString%' OR content LIKE '%$searchString%') UNION (SELECT title, content FROM comments WHERE title LIKE '%$searchString%' OR content LIKE '%$searchString%') UNION (SELECT title, content FROM events WHERE title LIKE '%$searchString%' OR content LIKE '%$searchString%')"; $searchResult = mysql_query($searchQuery) or die("Error in query $searchQuery: " . mysql_error()); list($itemTitle, $itemContent) = mysql_fetch_row($searchResult); Then I want the page to direct the user to page.php if the result is from the pages table, post.php if the result is from the posts table, comment.php if the result is from the comments table, and event.php if the result is from the events table. This is the part that isn't working: if (mysql_field_table == 'pages') { $link = 'page.php'; } elseif (mysql_field_table == 'posts') { $link = 'post.php'; } elseif (mysql_field_table == 'comments') { $link = 'comment.php'; } else { $link = 'event.php'; } However, when the page is rendered it thinks everything is an event and links each item in the search result to event.php. How do I fix this? Is there a simpler method? Link to comment https://forums.phpfreaks.com/topic/115594-mysql_field_table-not-working-the-way-i-want-it-to/ Share on other sites More sharing options...
Guest Posted July 19, 2008 Share Posted July 19, 2008 I'm not sure how to edit my previous post so I will just reply. My mysql function is all wrong, but that still doesn't explain why it isn't working. The correct function looks like this: mysql_field_table($searchResult, 0). Link to comment https://forums.phpfreaks.com/topic/115594-mysql_field_table-not-working-the-way-i-want-it-to/#findComment-594256 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.