SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2003
    Location
    Washington, DC
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP explode problems

    I'm guessing this might have to do with my use of explode... not sure. Anyway here is what is happening when I use the code below.



    As you can see the thumbnails for December 8th at 1:00 PM don't show. Not sure why...

    Here is the code..

    PHP Code:
    $q mysql_query("SELECT * FROM activity ORDER BY `id` DESC LIMIT 0,10");
      while (
    $list mysql_fetch_object($q)) {
        echo 
    "<h2><a href=\"./activity/$list->id/\">$list->title added for $list->date</a></h2>";
          
          
    $mid explode("||",$list->mid);
          
    $file_name explode("||",$list->file_name);
          
    $type explode("||",$list->type);
          
    $file_type explode("||",$list->file_type);
          
    $file_title explode("||",$list->file_title);
          
    $count_values sizeof($mid);

          
    //loop 

          
    while ($loop_count $count_values) {
            if (
    strlen($loop_count) < 1) {
              
    $media_mid $mid[0];
              
    $media_file_type $file_type[0];
              
    $media_file_name $file_name[0];
              
    $media_file_title $file_title[0];
              
    $media_type $type[0];
              } else {
              
    $media_mid $mid[$loop_count];
              
    $media_file_type $file_type[$loop_count];
              
    $media_file_name $file_name[$loop_count];
              
    $media_file_title $file_title[$loop_count];
              
    $media_type $type[$loop_count];
              }
            
            
    $media_file_title str_replace("'","",$media_file_title);
            
    $media_file_title str_replace("\"","",$media_file_title);

            if (
    $media_file_type == "youtube") {
              
    $thumbnail "http://img.youtube.com/vi/$media_file_name/1.jpg";
              } else {
              
    $thumbnail "./images/thumbnail/$media_file_name";
            }
            echo
            
    "<a href=\"./view/$media_type/$media_mid/\" title=\"$media_file_title\">
              <span class=\"thumbnail\" style=\"background:url(
    $thumbnail);\">
              <p>
    $media_type</p>
              </span>
             </a>"
    ;
            
    $loop_count++;
         }
      } 
    anyone seen my website link?

  2. #2
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do the images exist?
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  3. #3
    SitePoint Zealot
    Join Date
    Apr 2003
    Location
    Washington, DC
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes...
    anyone seen my website link?

  4. #4
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can the images be viewed if you go directly to it in a browser? The problem is either the image doesn't exist, or the image is broken.
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  5. #5
    SitePoint Zealot
    Join Date
    Apr 2003
    Location
    Washington, DC
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well actually the source shows that the html isn't even echoed for that area... and even if the images didn't exist the css for the thumbnail attribute has a width and height defined that would display regardless of an image displaying or not.
    anyone seen my website link?

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,044
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)
    If the HTML isn't being echo-ed, then that means the condtion of
    PHP Code:
    while ($loop_count $count_values) { 
    isn't being met. That is, for some reason $loop_count is > or = to $count_values.
    PHP Code:
    $count_values sizeof($mid); 
    but where is $loop_count being initialized?

    It looks like the first pass is bringing $loop_count up to 2, on the second pass 2 is not less than 2, so it doesn't enter the while, and on the third pass 2 is less than 11, so it will echo for [3] to [10] (showing the last 8).

  7. #7
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by zealivity5 View Post
    Well actually the source shows that the html isn't even echoed for that area... and even if the images didn't exist the css for the thumbnail attribute has a width and height defined that would display regardless of an image displaying or not.
    Ah! That little bit of information would have been helpful sooner .

    try adding a $loop_count = 0; before the while loop.
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!


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
  •