SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot BuyAnswersLinks's Avatar
    Join Date
    Aug 2008
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    clear out emptys

    Hello,

    I am making a ping script and need to not ping the urls that are empty in my db. I know how to use the empty() code but I do not know the easiest way to apply it to the code below.

    Basicly, with the code below. I only need the urls that are no empty in the array. Right now it will run blank rows in the script. thanks in advance

    PHP Code:
    $sql "SELECT `email`,`url`,`url_two`,`url_three`,`url_four`,`url_five`,`url_six`,`url_seven`,`url_eight`,`url_nine`,`url_ten` FROM `out` WHERE `ping_tool`='T' AND `ping_tool_user`='T'";
    $result mysql_query($sql) or die(mysql_error()); 
    while (
    $row mysql_fetch_object($result)) {

    $url_main str_replace("http://","",strtolower(trim($row->url)));
    $url_two str_replace("http://","",strtolower(trim($row->url_two)));
    $url_three str_replace("http://","",strtolower(trim($row->url_three)));
    $url_four str_replace("http://","",strtolower(trim($row->url_four)));
    $url_five str_replace("http://","",strtolower(trim($row->url_five)));
    $url_six str_replace("http://","",strtolower(trim($row->url_six)));
    $url_seven str_replace("http://","",strtolower(trim($row->url_seven)));
    $url_eight str_replace("http://","",strtolower(trim($row->url_eight)));
    $url_nine str_replace("http://","",strtolower(trim($row->url_nine)));
    $url_ten str_replace("http://","",strtolower(trim($row->url_ten)));

    $random_url = array($url_main$url_two$url_three$url_four$url_five$url_six$url_seven$url_eight$url_nine$url_ten);
    $random_random array_rand($random_url);
    $domainbase $random_url[$random_random];



  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $random_url array_filter(array($url_main$url_two$url_three$url_four$url_five$url_six$url_seven$url_eight$url_nine$url_ten)); 

    Ps, you might consider redesigning the database. You have a ton of repeating columns. You could do a web search for database normalization to learn more.

  3. #3
    SitePoint Zealot BuyAnswersLinks's Avatar
    Join Date
    Aug 2008
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK thank you I appreciate the tips


Bookmarks

Posting Permissions

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