|
-
Sep 16th, 2003, 11:28 PM
#1
PHP/MySQL search engine.. [resolved]
Ok, I've made this search engine, and it works fine how it is, but I just want to add something to it. I want to add something to it so that it will count how many times it found the search query in every result it found. The search engine basically just looks in my MySQL database for the query, and then returns the results for you to be able to look over or whatever you want. I figured I wanted to be able to search through stuff and see how many times a word or whatever was found within the results, so now I'm trying to do that. Anyway, here's the raw code of the script I'm using:
Note: basically, the things I'm looking inside of for the results are $j['j_subject'] and $j['j_post'].
Another note: I realize my programming skills are probably pretty weak.. but it works. Feel free to clean it up or something, if you feel so obliged.
PHP Code:
<center>
<table width="375" cellpadding="0" cellspacing="0" class="users">
<tr width="100%">
<td width="50" class="users-top" align="center">ID</td>
<td width="200" class="users-top">Entry Title</td>
<td width="75" class="users-top">Date</td>
<td width="25" class="users-top">FND</td>
</tr>
<?
$c = "SELECT COUNT(*) FROM $mysql[journal] WHERE j_subject LIKE '%" . $_GET['query'] . "%' OR j_post LIKE '%" . $_GET['query'] . "%'";
$c = mysql_query($c);
$c = mysql_fetch_array($c);
$jq = "SELECT j_id, j_subject, j_post, j_date FROM $mysql[journal] WHERE j_subject LIKE '%" . $_GET['query'] . "%' OR j_post LIKE '%" . $_GET['query'] . "%'";
$jq = mysql_query($jq);
while($j = mysql_fetch_array($jq)){
$found = 0;
/* ADD HOW TO FIND VARIABLES IN HERE */
echo " <tr width=\"100%\">\n";
echo " <td width=\"50\" class=\"users-data\" align=\"center\">$j[j_id]</td>\n";
echo " <td width=\"200\" class=\"users-data\"><a href=\"?act=journal_comm&id=$j[j_id]\">$j[j_subject]</a></td>\n";
echo " <td width=\"75\" class=\"users-data\">$j[j_date]</td>\n";
echo " <td width=\"25\" class=\"users-data\">$found</td>\n";
echo " </tr>\n";
}
echo " <tr width=\"100%\">\n";
echo " <td colspan=\"3\" class=\"users-bottom\">$c[0] entries found</td>\n";
echo " </tr>\n";
?>
</table>
</center>
For all I know, it's something really simple that I could do and it's just not comming to me. There's alot on my mind so I'm trying to take my mind off of it with some programming but I'm just have some troubles.. Any help is appreciated.
edit: removed some code that had page-specific formatting and some other stuff that used my own functions that might've confused anyone.. also removed some useless html formatting for easier reading
Last edited by kows; Sep 17th, 2003 at 11:15 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|