Jump to content

question for positioning forum output ect...


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 post
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 post
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 post
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 post
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 post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...