Arne-Christian 0 Report post Posted September 26, 2006 I am currently expericing a problem with the following code: $db = new db; $db->connect(); $forum_mod = $db->query("SELECT * FROM eb_moderator WHERE `forum_id` = '{$forum_id}';"); $moderator = "<strong>Moderators:</strong> "; while ( $mod = mysql_fetch_array($forum_mod)) { $mod_name = $mod['member_name']; if($mod['member_name'] !== "") { $moder = " <a href=\"index.php?act=members&memberid={$mod['member_id']}\">" . $mod_name . "</a>,"; } if($mod['member_name'] == "") { $moder = "none"; } $moderator = $moderator . $moder; } Does anybody got an idea how to fix this? Share this post Link to post Share on other sites
Saint_Michael 3 Report post Posted September 26, 2006 I can tell its a forum script, but what forum are you using and what mod are you putting in? Share this post Link to post Share on other sites
jlhaslip 4 Report post Posted September 26, 2006 What is (or isn't) happening correctly? Share this post Link to post Share on other sites
Arne-Christian 0 Report post Posted September 26, 2006 (edited) Saint Michael: Its my own forum i am creating, so its no mod jlhaslip: Well it prints out the correnct information one place (Name of the moderator), BUT when there isn't a moderator at forum X it should print out none, but here comes the tricy part, it dosnt do that -.-, give me 1 minute i will take a screenshot Edit: Edited September 26, 2006 by Arne-Christian (see edit history) Share this post Link to post Share on other sites
jlhaslip 4 Report post Posted September 26, 2006 What is the purpose of this code segment? if($mod['member_name'] == "") { $moder = "none"; } $moderator = $moderator . $moder; If you want to print "none" for the number of Moderators, check the mysql query results array for the number of results and then perform the while loop inside the loop?if ( count(mysql_fetch_array($forum_mod)) > 0) { while( $mod = mysql_fetch_array($forum_mod)) { $mod_name = $mod['member_name']; if($mod['member_name'] !== "") { $moder = " <a href=\"index.php?act=members&memberid={$mod['member_id']}\">" . $mod_name . "</a>,";echo $moder; }else {echo "none";} I don't know if all the code is correct, but the logic might work differently than what you have now.Treat this as pseudo-code. Share this post Link to post Share on other sites
Arne-Christian 0 Report post Posted September 26, 2006 I fixed it now, with a little bit help form your code $rows = mysql_num_rows($forum_mod); if ($rows > 0) { while ( $mod = mysql_fetch_array($forum_mod)) { $mod_name = $mod['member_name']; if(count($mod['member_name']) > 0) { $eb_moderator = "<strong>Moderators:</strong> "; $eb_moderator .= " <a href=\"index.php?act=members&memberid={$mod['member_id']}\">" . $mod_name . "</a>,"; } } } else { $eb_moderator = "<strong>Moderators:</strong> "; $eb_moderator .= "<i>None</i>"; }thats the new code Thanks for the fast respondes I will add Xisto.com to special thanks to on my credits page Share this post Link to post Share on other sites
jlhaslip 4 Report post Posted September 27, 2006 Aw, shucks. It was nothing.Xisto appreciates all its members and if you would pass the word around, it will only make this a better place.Good luck on your project. Share this post Link to post Share on other sites