Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
  1. #1
    Senior Member Seldimi's Avatar
    Join Date
    Dec 2002
    Location
    Kozani, Greece
    Posts
    488
    Member #
    409
    Hello, can sb make me a PHP code for this one ??? I use MySQL to store the "date" and "hits" values where data is stored. I need it for my Script Index direcotry.
    (I know its a similar post but couldnt undestand the way )
    - Webmaster's Planet . Greek Vortal For Webmasters ...
    - MyPortFolio - View My Creations

  2.  

  3. #2
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    JR

  4. #3
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    For your 5 most recent:
    Code:
    SELECT * FROM counter_table ORDER BY date_column DESC LIMIT 5
    for your 5 most popular:
    Code:
    SELECT * FROM counter_table ORDER BY hits_column DESC LIMIT 5

  5. #4
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    and the php code would be this (helped by my question about top 10, correct me if i am wrong)...
    PHP Code:
    <html>
    <head>
    <?php
    $user
    ="[i]username[/i]";
    $host="localhost";
    $password="[i]password[/i]";
    $database="[i]database name[/i]";
    $connection mysql_connect($host$user$password)
    or die (
    "Couldn't Connect, please try later");
    $db mysql_select_db($database,$connection)
    or die (
    "Couldn't Connect to Database, please try later");

    $datelist="SELECT * FROM counter_table ORDER BY date_column DESC LIMIT 5";
    $hitlist="SELECT * FROM counter_table ORDER BY hits_column DESC LIMIT 5";


    $datequery=mysql_query($datelist);
    while(
    $daterow mysql_fetch_array($datequery))
    {
        
    $dates $hitrow['hits_column']."</br>";
    }

    $hitquery=mysql_query($hitlist);
    while(
    $hitrow mysql_fetch_array($hitquery))
    {
        
    $hits $hitrow['hits_column']."</br>";
    }
    ?>
    </head>
    <body>
    <?php echo $dates?>
    <?php 
    echo $hits?>
    </body>
    </html>
    i know this is probably wrong so i am relying on you guys to correct it for me
    JR

  6. #5
    Senior Member Seldimi's Avatar
    Join Date
    Dec 2002
    Location
    Kozani, Greece
    Posts
    488
    Member #
    409
    PHP Code:
    while($daterow mysql_fetch_array($datequery))
    {
        
    $dates $daterow['added']."</br>";

    I think that's correct (no both hits_colum)
    Also these:
    hits_colum = hitsout
    date_colum = added
    counter_table = php_scripts

    (I get this error : Parse error: parse error, unexpected T_STRING in /home/wplanet/public_html/test/test.php on line 16) http://www.webmastersplanet.com/test/test.php
    - Webmaster's Planet . Greek Vortal For Webmasters ...
    - MyPortFolio - View My Creations

  7. #6
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    I don't know what the PHP error is, but what the heck is </br> ??? that's not any HTML element that I know of !!! ;-)

  8. #7
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    LOL, i meant to remove that :classic:, somebody will come along soon to sort that code out, because i know next to nothing about php
    JR

  9. #8
    Senior Member Seldimi's Avatar
    Join Date
    Dec 2002
    Location
    Kozani, Greece
    Posts
    488
    Member #
    409
    I fixed <br> but still doesn't work
    - Webmaster's Planet . Greek Vortal For Webmasters ...
    - MyPortFolio - View My Creations

  10. #9
    Senior Member Seldimi's Avatar
    Join Date
    Dec 2002
    Location
    Kozani, Greece
    Posts
    488
    Member #
    409
    Noone wants to help me ?
    Even you transio ? You help most people
    - Webmaster's Planet . Greek Vortal For Webmasters ...
    - MyPortFolio - View My Creations

  11. #10
    Senior Member Seldimi's Avatar
    Join Date
    Dec 2002
    Location
    Kozani, Greece
    Posts
    488
    Member #
    409
    I made this one for 5 last added
    PHP Code:
    <html>
    <head>
    <?php
    $user
    ="username";
    $host="localhost";
    $password="password";
    $database="database name";
    $connection mysql_connect($host$user$password)
    or die (
    "Couldn't Connect, please try later");
    $db mysql_select_db($database,$connection)
    or die (
    "Couldn't Connect to Database, please try later");

    $query "SELECT * FROM php_scripts ORDER BY hitsout DESC LIMIT 0, 5";
    $result mysql_query($query);
    $url_query "SELECT * FROM php_scripts ORDER BY hitsout DESC LIMIT 0,5";
    $url_result mysql_query($url_query);

    $msg_array "";
    $i=0;

    while(
    $row mysql_fetch_array($result))
    {
        
    $msg_array[$i] = $row['title'];
        
    $i++;
    }

    $url_array"";
    $i=0;
    while(
    $url_fetchmysql_fetch_array($url_result))
    {
         
    $url[$i] = $url_fetch['homeurl'];
      
    $i++;
    }

    ?>
    <title>Top 5 with URL</title>
    </head>
    <body>
    <a href="<?php echo $url[0]; ?>"><?PHP echo $msg_array[0]; ?></a>
    <a href="<?php echo $url[1]; ?>"><?PHP echo $msg_array[1]; ?></a>
    <a href="<?php echo $url[2]; ?>"><?PHP echo $msg_array[2]; ?></a>
    <a href="<?php echo $url[3]; ?>"><?PHP echo $msg_array[3]; ?></a>
    <a href="<?php echo $url[4]; ?>"><?PHP echo $msg_array[4]; ?></a>
    <a href="<?php echo $url[5]; ?>"><?PHP echo $msg_array[5]; ?></a>
    </body>
    It Works GREAT !!!
    - Webmaster's Planet . Greek Vortal For Webmasters ...
    - MyPortFolio - View My Creations


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:35 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com