Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jan 2010
    Location
    Washington
    Posts
    223
    Thanks
    34
    Thanked 0 Times in 0 Posts

    Question Why wont this work correctly?

    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 Code:
    <?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

    Code:
    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..
    Code:
    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?

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,862
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    <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.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    Jan 2010
    Location
    Washington
    Posts
    223
    Thanks
    34
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by abduraooft View Post
    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.

  • #4
    Regular Coder
    Join Date
    Jan 2010
    Location
    Washington
    Posts
    223
    Thanks
    34
    Thanked 0 Times in 0 Posts
    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?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •