...

View Full Version : Why wont this work correctly?



cosmicsea
11-03-2010, 07:09 AM
This code is for a tag cloud "last 10 searches for search engine". It shows what I want it to show but only the first row in the table works, Anything after the first keyword is just jumbled all together. Can anyone tell me why all the rows after the first will not work correctly?


<?php
$class = "evrow";
echo "
<p class='headline cntr sml'>Search Log (Latest 10)</p>
<table width='100%'>
<tr>
<td class='tblhead'>Query</td>
<td class='tblhead'>Results</td>
<td class='tblhead'>Queried at:</td>
</tr>
";
$num = '1';
$result=mysql_query("select query, date_format(time, '%Y-%m-%d %H:%i:%s'), results from ".$mysql_table_prefix."query_log order by time desc");
if ($debug > '0') echo mysql_error();
while (($row=mysql_fetch_row($result)) && ($num <= '10')) {
if ($class =="evrow")
$word = $row[0];
$time = $row[1];
$results = $row[2];
echo "<tr class='$class'>
<td><a href='../search.php?query=$word&amp;search=1' target='rel' title='View search results in new window'>".($word)."</a></td>
<td class='cntr sml'> ".$results."</td>
<td class='cntr sml'> ".$time."</td>
<td class='cntr sml'> ".$elapsed."</td>
</tr>
";
$num++;
echo "
</table>
";
}

?>


its supposed to look like this



Query Results Queried at:
Keyword 192 2010-11-02 23:15:37
blah 854 2010-11-02 23:15:10
and so on


But it looks like this..


Query Results Queried at:
keyword 192 2010-11-02 23:15:37
blah 268 2010-11-02 23:15:10 cool 9999 2010-11-02 20:53:23 boat 9999 2010-11-02 20:50:41 cool 9999 2010-11-02 19:53:00 forum 90 2010-11-02 19:41:10 php 4015 2010-11-02 19:14:32 dude 4015 2010-11-02 18:28:13 guy 268 2010-11-02 18:09:10 girl 94 2010-11-02 15:56:27 person 3444 2010-11-02 13:35:01

Can anyone help fix that?
And it is also showing the same keyword more than once if searched at different times. What could I do to make it so if lets say "blah" was the third keyword searched and if searched again it just brings it to the top and updates it?

abduraooft
11-03-2010, 11:29 AM
<tr>
<td class='tblhead'>Query</td>
<td class='tblhead'>Results</td>
<td class='tblhead'>Queried at:</td>
</tr> You have 3 columns at the top and 4 columns at the bottom.

cosmicsea
11-03-2010, 12:12 PM
You have 3 columns at the top and 4 columns at the bottom.

from what i can see and have tried. The table is not the problem. the first result works fine but everything after is clustered. maybe i am just tired and it is the table but I really don't believe it is.

cosmicsea
11-03-2010, 12:27 PM
I have it working now. I tried something else but now I have a problem where the search keyword repeats in the tag cloud. Like if someone searched for boat and then water and then boat again it would show in the tag cloud like so
boat
water
boat

I don't know how to not make it repeat and just bring to the top if it was searched. how would I go about doing this?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum