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.

Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Mar 2003
    Posts
    2
    Member #
    790
    What would I need to do here to only print the ip's that the first 5 numbers in the ip are the same?

    Code:
    <?php
    require "./con.php";
    include "./header.inc";
    $result = mysql_query("SELECT ip, id FROM employees",$db);
    
        while ($myrow = mysql_fetch_array($result)) {
    echo "<table border=1>";
    printf("<tr><td width=300><a href=\"%s?id=%s\">%s</a></td> \n", "index.php", $myrow["id"], $myrow["ip"]);
    
    echo "</table>";
        }
    include "./footer.inc";
    ?>
    Any help appreciated.

  2.  

  3. #2
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    First, don't use SELECT *. Instead, always select just what you need and nothing more.

    Second, try using LIMIT 5 to only return at most five rows
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  4. #3
    Junior Member
    Join Date
    Mar 2003
    Posts
    2
    Member #
    790
    I understand the select* comment. However what I meant to say was I only want to print if the first 5 numbers match the first 5 numbers of another IP.

  5. #4
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Try:
    PHP Code:
    if (substr(str_replace("."""$myrow['id']), 05) ==
        
    substr(str_replace(".""""12.34.56.78"), 05))
    {
        ...

    Looks horrible but should work.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!


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 02:40 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com