Jump to content

question for positioning forum output ect...


rootKID

Recommended Posts

Hello w3s.i'm not sure if i have asked in the right forum, was unsure if i should put the question in PHP or SQL area, anyways. i have attached a image where i show my so called forum so far made myself without trouble.Now i have ran into trouble that i would like to ask help for. LOOK AT PICTURE FOR THE IDEA here is my code: Menu:

$HTMLOUT .= box_start("Forum Menu");$fm_res = mysql_query("SELECT * FROM mod_forum_menu ORDER BY fm_id ASC");$get_fc_id = (isset($_GET['fc_id']) ? '?fc_id='.$_GET['fc_id'].'&' : '?');//if isset...if (mysql_num_rows($fm_res) > 0)//if bigger than 0...{while($fm_array = mysql_fetch_assoc($fm_res))//fm = forum_menu{  $HTMLOUT .= "(<a href='forums_v1.php".$get_fc_id."fm_id=".$fm_array['fm_id']."' alt='".$fm_array['fm_name']."'>".$fm_array['fm_name']."</a>) ";}}else{$HTMLOUT .= "No forum menu added yet, please contact First Line Support for further information!...";}$HTMLOUT .= box_end();

Forum Categories:

/*Category Forums...*/if(isset($_GET['fm_id'])){$fc_res = mysql_query("SELECT * FROM mod_forum_cats WHERE fc_id = ".$_GET['fm_id']);}else{$fc_res = mysql_query("SELECT * FROM mod_forum_cats ORDER BY fc_id ASC");}/*Category Forums...*/$get_fm_id = (isset($_GET['fm_id']) ? '?fm_id='.$_GET['fm_id']."&" : '?');//if isset...if (mysql_num_rows($fc_res) > 0)//if bigger than 0...{//$HTMLOUT .= "Forum(s) succes showed...<br />";while($fc_array = mysql_fetch_assoc($fc_res))//fc = forum_category{  $HTMLOUT .= "<div id='forum_cats_title_wrapper'>";  $HTMLOUT .= "<a href='forums_v1.php".$get_fm_id."fc_id=".$fc_array['fc_id']."'>".$fc_array['fc_name']."</a><-FORUM CATEGORY LIKE LH!...";  $HTMLOUT .= "</div>";   $HTMLOUT .= "<div id='under_forum_cats_title_wrapper'>";  $HTMLOUT .= "--<a href='#'>ACTUAL FORUM 1 HERE...</a><br />";  $HTMLOUT .= "--<a href='#'>ACTUAL FORUM 2 HERE...</a>";  $HTMLOUT .= "</div>";}}else{if($CURUSER['class'] >= UC_ADMIN)//equal or over ADMIN level for this message...{  $HTMLOUT .= "  Admin Message:<br /><br />  Remember to add a Forum category before the real forums can be showed!...";}else{  $HTMLOUT .= "No forum categories added yet, please contact First Line Support for further information!...";}}

now, i have done almost everything correct, i think, i have not errors so far.My trouble now lies in that i need to output the actual forums lying under the Forum Categories...how to do this in an another SQL?, the current one as you see is inside a while loop, and i should as far as i have been thinking, be in the same while loop... ideas?... PS:if you need more info, tell me so and i will try to explain in details of what i am doing, thanks again! :)...

Link to comment
Share on other sites

The easiest way is to just add another query inside the loop to look up forums for each category you're displaying. You're not protecting against SQL injection though, you should be sanitizing any input that you're using in a query. It's also not really a good idea to be using the mysql extension at this point, it's going away soon. The mysqli or PDO extensions would be better.

Link to comment
Share on other sites

i know about the sql_injection, ill do that when i have made up the working code :) and about the query, can i make an another query line (inside) the while loop, would that not just give an error?, or did i misunderstood something?...

Link to comment
Share on other sites

ok, as you see, i have done as you said, so far so good... but as you also see in my DB, there should at least get 2 at each and one of forums.. why only 1 at each?, ideas?... SQL:

while($fc_array = mysql_fetch_assoc($fc_res))//fc = forum_category{  $HTMLOUT .= "<div id='forum_cats_title_wrapper'>";  $HTMLOUT .= "<a href='forums_v1.php".$get_fm_id."fc_id=".$fc_array['fc_id']."'>".$fc_array['fc_name']."</a><-FORUM CATEGORY LIKE LH!...";  $HTMLOUT .= "</div>";   //Actual Forums Query...  $f_res = mysql_query("SELECT * FROM mod_forums WHERE f_FK_forumcat_id = ".$fc_array['fc_id']);  $f_array = mysql_fetch_assoc($f_res);   $HTMLOUT .= "<div id='under_forum_cats_title_wrapper'>";  $HTMLOUT .= "--<a href='#'>".$f_array['f_name']."</a>";  $HTMLOUT .= "</div>";}

Edited by rootKID
Link to comment
Share on other sites

ohh... oops.. so am i to understand it this way, a while more, inside the while itself? Oo... EDIT: Done, and working.. thanks! :)...

Edited by rootKID
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...