techiefreak05 Posted September 11, 2006 Share Posted September 11, 2006 i have a code that gets all your friends from the "friends": table... and then takes that info and gets all the bulletins from the "bulletins" table and then shows all the bulletins posted by all your friends... .. but its not working.. no error.. its just the bulletins are not showing up ...[code]<?php$query="SELECT * FROM friends WHERE `username` = '$_SESSION[username]' AND `accepted` = 'yes'";$result=mysql_query($query);while($array=mysql_fetch_assoc($result)){$poster = $array['friend'];$user = $_SESSION[username];if(!isset($_GET['bulletinPage'])){ $Bpage = 1; } else { $Bpage = $_GET['bulletinPage']; } $max_results = 5; $from = (($Bpage * $max_results) - $max_results); $query="SELECT * FROM `bulletins` WHERE `from` = '$poster' ORDER by 'id' DESC LIMIT $from, $max_results";$result=mysql_query($query);while($array=mysql_fetch_assoc($result)){echo "<table bgcolor=#99CCFF width=200><tr bgcolor=#548099><td height=28><b><font color=white>From: <a href='getInfo.php?user=" . $array['from'] . "'>" . $array['from'] . "</a></b><br><b>Date: </b>" .$array['date']; echo "</b></font></td></tr></table>"; echo "<table bgcolor=#99CCFF width=200><tr bgcolor=#356B8B><td height=25><center><a href=\"showBulletin.php?id=".$array['id']."\">Subject: ".$array['subject']."</a></center>"; echo "</td></tr></table><hr>"; }}[/code]some of the code in there is the pagination code.... Link to comment https://forums.phpfreaks.com/topic/20346-mysql-query-inside-another-mysql-while-loop-need-some-help/ Share on other sites More sharing options...
btherl Posted September 11, 2006 Share Posted September 11, 2006 It's good practice to check mysql_query() for errors.[code]$result = mysql_query($query);if ($result === false) die("Mysql error: " . mysql_error() " on query $query\n");[/code]If that doesn't work, then print out your queries before executing them. It's likely there's a problem with one of them. Link to comment https://forums.phpfreaks.com/topic/20346-mysql-query-inside-another-mysql-while-loop-need-some-help/#findComment-89684 Share on other sites More sharing options...
Jenk Posted September 11, 2006 Share Posted September 11, 2006 Where do you start the session, and where do you check that $_SESSION['username'] has a value?Also, learn to use JOIN's and not nested mysql_query()'s. Link to comment https://forums.phpfreaks.com/topic/20346-mysql-query-inside-another-mysql-while-loop-need-some-help/#findComment-89693 Share on other sites More sharing options...
techiefreak05 Posted September 11, 2006 Author Share Posted September 11, 2006 the answer to both ur questions:: [b]earlier in the code[/b] Link to comment https://forums.phpfreaks.com/topic/20346-mysql-query-inside-another-mysql-while-loop-need-some-help/#findComment-90038 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.