Jump to content

displaying some data


sstangle73

Recommended Posts

Allright!

So i have this script where it pulls data from one db and uses that data to pull from 2 more dbs.  The problem is with one of the later dbs when i run that query the friends who dont have an image in the DB end up not showing up at all with or without a "no image" image.  Without the query on the image db everything runs fine and the "no image" image is shown.

 

heres pictures + code

with query:

<?php
$i = 0;
$queryfriends="SELECT * FROM friends WHERE ID = '$pID' && `Accepted`='1'"; 
$resultfriends=mysql_query($queryfriends) or die(mysql_error()); 
while($arrayfriends=mysql_fetch_array($resultfriends)){
    $queryusers="SELECT * FROM users WHERE ID = '$arrayfriends[Friend_ID]'"; 
    $resultusers=mysql_query($queryusers) or die(mysql_error()); 
    while($arrayusers=mysql_fetch_array($resultusers)){
        $queryimages = "SELECT * FROM image WHERE ID = '$arrayfriends[Friend_ID]' && `Default` = '1'";
        $resultimages = mysql_query($queryimages) or die(mysql_error()); 
        while($arrayimages=mysql_fetch_array($resultimages)){
        $URL = $arrayimages['URL'];
            if($resultfriends && mysql_num_rows($resultfriends) > 0){
            $max_columns = 3;
                if($i == 0){
                echo "<tr>";
                }
                echo "<td><a href=\"" . $arrayfriends[Friend_ID] . "\">";
                if(empty($URL)){ echo "<img src=\"http://x.myspace.com/images/no_pic.gif\" width=\"90px\" height=\"100px\" border=\"0\">"; }else{ echo "<img src=\"" . $URL . "\" width=\"90px\" height=\"100px\" border=\"0\">";}
                echo "</a><br>";
                echo "<a href=\"" . $arrayfriends[Friend_ID] . "\"><b>" . $arrayusers[dname] . "</b></a>";
                echo "</td>";
			$i ++;
                if($i == $max_columns){
                echo "</tr>";
                $i = 0;
                }
            }
        }
    }
}
if($i < $max_columns){
for($j=$i; $j<$max_columns;$j++)
echo "<td> </td>";
}
?>

 

img.jpg

w/o:

<?php
$i = 0;
$queryfriends="SELECT * FROM friends WHERE ID = '$pID' && `Accepted`='1'"; 
$resultfriends=mysql_query($queryfriends) or die(mysql_error()); 
while($arrayfriends=mysql_fetch_array($resultfriends)){
    $queryusers="SELECT * FROM users WHERE ID = '$arrayfriends[Friend_ID]'"; 
    $resultusers=mysql_query($queryusers) or die(mysql_error()); 
    while($arrayusers=mysql_fetch_array($resultusers)){
      //  $queryimages = "SELECT * FROM image WHERE ID = '$arrayfriends[Friend_ID]' && `Default` = '1'";
      //  $resultimages = mysql_query($queryimages) or die(mysql_error()); 
      //  while($arrayimages=mysql_fetch_array($resultimages)){
        $URL = $arrayimages['URL'];
            if($resultfriends && mysql_num_rows($resultfriends) > 0){
            $max_columns = 3;
                if($i == 0){
                echo "<tr>";
                }
                echo "<td><a href=\"" . $arrayfriends[Friend_ID] . "\">";
                if(empty($URL)){ echo "<img src=\"http://x.myspace.com/images/no_pic.gif\" width=\"90px\" height=\"100px\" border=\"0\">"; }else{ echo "<img src=\"" . $URL . "\" width=\"90px\" height=\"100px\" border=\"0\">";}
                echo "</a><br>";
                echo "<a href=\"" . $arrayfriends[Friend_ID] . "\"><b>" . $arrayusers[dname] . "</b></a>";
                echo "</td>";
			$i ++;
                if($i == $max_columns){
                echo "</tr>";
                $i = 0;
                }
            }
       // }
    }
}
if($i < $max_columns){
for($j=$i; $j<$max_columns;$j++)
echo "<td> </td>";
}
?>

 

img2.jpg

 

Thanks For The Help!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.