sstangle73 Posted March 30, 2008 Share Posted March 30, 2008 ok what i am doing is pulling stuff from three different databases and then displaying it in rows of 4 im so confused right now as to what the hell im doing sssssoooooooo if anyone wants to help me can you message me on aim sstangle73 or post in this thread thanks oh btw what i have displays nothing <table cellspacing="3" cellpadding="3"> <?php $query56="SELECT * FROM friends WHERE ID = '$pID' && `Accepted`='1'"; $result56=mysql_query($query56) or die(mysql_error()); while($array56=mysql_fetch_assoc($result56)){ $query6 = "SELECT * FROM image WHERE ID = '$result56[Friend_ID]' && `Default` = '1'"; $result6 = mysql_query($query6) or die("There was a problem with the SQL query: " . mysql_error()); if($result6 && mysql_num_rows($result6) > 0) { $i = 0; $max_columns = 4; while($row = mysql_fetch_array($result6)) { $URL = $row['URL']; $query561="SELECT * FROM users WHERE ID = '$result56[Friend_ID]'"; $result561=mysql_query($query561) or die(mysql_error()); while($array561=mysql_fetch_assoc($result561)){ $fdname = $array561['dname']; // make the variables easy to deal with // open row if counter is zero if($i == 0) echo "<tr>"; // make sure we have a valid product if($URL != "" && $URL != null) echo "<td><table><tr><td><a href=\"" . $result56[Friend_ID] . "\"><img src=" . $URL . " width=90px height=110px></a></td></tr>"; echo "<tr><td><center><b>" . $fdname . "</b></center></td></tr></table></td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } } } // end while } // end if results // clean up table - makes your code valid! if($i < $max_columns) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; } ?> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/98725-displaying-some-data-from-db/ Share on other sites More sharing options...
sstangle73 Posted March 31, 2008 Author Share Posted March 31, 2008 my brain hurts Link to comment https://forums.phpfreaks.com/topic/98725-displaying-some-data-from-db/#findComment-505248 Share on other sites More sharing options...
maxudaskin Posted March 31, 2008 Share Posted March 31, 2008 Let me help your brain out. Organize your script... <?php $variable = "value"; if($variable != "something"){ // Checks if $variable is not equal to something echo "Variable actually says: " . $variable; // Variable is not equal to something }else{ // Variable is equal to something while($i != 10){ // If $i is not equal to 10 do this echo $i; // Output $i $i++; // Increase $i by one } } ?> See how I indented the code and added comments in the appropriate sections? You can also align the variables... <?php $that = 9; $goo = 65; $apples_and_bananas = "yum"; ?> Please note that in the above code, it does not align because a space in your browser is not the same width as a character. In dreamweaver and notepad they are. Link to comment https://forums.phpfreaks.com/topic/98725-displaying-some-data-from-db/#findComment-505254 Share on other sites More sharing options...
sstangle73 Posted March 31, 2008 Author Share Posted March 31, 2008 Organized so now i need to figure out whats wrong. <table cellspacing="3" cellpadding="3"> <?php $query56="SELECT * FROM friends WHERE ID = '$pID' && `Accepted`='1'"; $result56=mysql_query($query56) or die(mysql_error()); while($array56=mysql_fetch_assoc($result56)){ $query6 = "SELECT * FROM image WHERE ID = '$result56[Friend_ID]' && `Default` = '1'"; $result6 = mysql_query($query6) or die("There was a problem with the SQL query: " . mysql_error()); if($result6 && mysql_num_rows($result6) > 0){ $i = 0; $max_columns = 4; while($row = mysql_fetch_array($result6)){ $URL = $row['URL']; $query561="SELECT * FROM users WHERE ID = '$result56[Friend_ID]'"; $result561=mysql_query($query561) or die(mysql_error()); while($array561=mysql_fetch_assoc($result561)){ $fdname = $array561['dname']; // make the variables easy to deal with // open row if counter is zero if($i == 0) echo "<tr>"; echo "<td><table><tr><td><a href=\"" . $result56[Friend_ID] . "\"><img src=" . $URL . " width=90px height=110px></a></td></tr>"; echo "<tr><td><center><b>" . $fdname . "</b></center></td></tr></table></td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns){ echo "</tr>"; $i=0; } // end if } } } // end while } // end if results // clean up table - makes your code valid! if($i < $max_columns) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; } ?> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/98725-displaying-some-data-from-db/#findComment-505286 Share on other sites More sharing options...
maxudaskin Posted March 31, 2008 Share Posted March 31, 2008 Screenshot of the table would be nice and providing what $pID is set to would help a lot... Link to comment https://forums.phpfreaks.com/topic/98725-displaying-some-data-from-db/#findComment-505292 Share on other sites More sharing options...
sstangle73 Posted March 31, 2008 Author Share Posted March 31, 2008 found some stupid things so now itll run once and come up with the URL for the 1st friend but after that it comes up blank <table cellspacing="3" cellpadding="3"> <?php $query56="SELECT * FROM friends WHERE ID = '$pID' && `Accepted`='1'"; $result56=mysql_query($query56) or die(mysql_error()); while($array56=mysql_fetch_assoc($result56)){ $query6 = "SELECT * FROM image WHERE ID = '$array56[Friend_ID]' && `Default` = '1'"; $result6 = mysql_query($query6) or die("There was a problem with the SQL query: " . mysql_error()); if($result6 && mysql_num_rows($result6) > 0){ $i= 0; $max_columns= 3; while($row = mysql_fetch_array($result6)){ $URL = $row['URL']; if('$URL' == '$row[\'URL\']'){ $URL = 'http://x.myspace.com/images/no_pic.gif'; } $query561="SELECT * FROM users WHERE ID = '$array56[Friend_ID]'"; $result561=mysql_query($query561) or die(mysql_error()); while($array561=mysql_fetch_assoc($result561)){ $fdname = $array561['dname']; // make the variables easy to deal with // open row if counter is zero if($i == 0){ echo "<tr>"; } echo "<td><table><tr><td><a href=\"" . $array56[Friend_ID] . "\"><img src=" . $URL . " width=\"90px\" height=\"100px\" border=\"0\"></a></td></tr>"; echo "<tr><td><center><a href=\"" . $array56[Friend_ID] . "\"><b>" . $fdname . "</b></a></center></td></tr></table></td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns){ echo "</tr>"; $i=0; } // end if } } } // end while } // end if results // clean up table - makes your code valid! if($i < $max_columns) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; } ?> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/98725-displaying-some-data-from-db/#findComment-505321 Share on other sites More sharing options...
sstangle73 Posted March 31, 2008 Author Share Posted March 31, 2008 gah! heres the most recent <table cellspacing="3" cellpadding="3"> <?php $query56="SELECT * FROM friends WHERE ID = '$pID' && `Accepted`='1'"; $result56=mysql_query($query56) or die(mysql_error()); while($array56=mysql_fetch_array($result56)){ $query6 = "SELECT * FROM image WHERE ID = '$array56[Friend_ID]' && `Default` = '1'"; $result6 = mysql_query($query6) or die("There was a problem with the SQL query: " . mysql_error()); if($result6 && mysql_num_rows($result6) > 0){ $i= 0; $max_columns= 3; while($row = mysql_fetch_array($result6)){ $URL = $row['URL']; if('$URL' == '$row[\'URL\']'){ $URL = 'http://x.myspace.com/images/no_pic.gif'; } $query561="SELECT * FROM users WHERE ID = '$array56[Friend_ID]'"; $result561=mysql_query($query561) or die(mysql_error()); while($array561=mysql_fetch_assoc($result561)){ $fdname = $array561['dname']; // make the variables easy to deal with // open row if counter is zero if($i == 0){ echo "<tr>"; } echo "<td><table><tr><td><a href=\"" . $array56[Friend_ID] . "\"><img src=" . $URL . " width=\"90px\" height=\"100px\" border=\"0\"></a></td></tr>"; echo "<tr><td><center><a href=\"" . $array56[Friend_ID] . "\"><b>" . $fdname . "</b></a></center></td></tr></table></td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns){ echo "</tr>"; $i=0; } // end if } } } // end while } // end if results // clean up table - makes your code valid! if($i < $max_columns) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; } ?> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/98725-displaying-some-data-from-db/#findComment-505337 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.