-
Posts
902 -
Joined
-
Last visited
-
Days Won
9
Everything posted by doddsey_65
-
i fixed it, just added an else statement to the is_array($forums['subforums']). also came across the problem of it only showing one subforum but i added $child['f_name'] to an array then imploded it. Again thanks alot for your help!
-
actually slight problem. I have a forum with a sunforum and a one without. For some reason it adds the sunforum of the first forum under the second one aswell. foreach($nforums as $cat) { $template->f_c_name = $cat[0]['f_name']; $template->is_cat = true; $template->render($template->template.'templates/forum_list_tpl.php'); if(is_array($cat[1])) { foreach($cat[1] as $forum) { $template->f_name = $forum['f_name']; $template->is_cat = false; if(is_array($forum['subforums'])) { foreach($forum['subforums'] as $child) { $template->subforums = $child['f_name']; } } $template->render($template->template.'templates/forum_list_tpl.php'); } } }
-
it was an issue with the rendering. i moved the rendering into the foreach loop and problem solved. Thanks alot for your help. I have been trying to solve this for about a month now! thanks!
-
thanks for the advice and code so far, youve been great. However it only displays one forum( i have 2 now to test). foreach($nforums as $cat) { $template->f_c_name = $cat[0]['f_name']; if(is_array($cat[1])) { foreach($cat[1] as $forum) { $template->f_name = $forum['f_name']; if(is_array($forum['subforums'])) { foreach($forum['subforums'] as $child) { $template->subforums = $child['f_name']; } } } } $template->render($template->template.'templates/forum_list_tpl.php'); } The render function basically sends the values defined using $template to a php tpl file which contains(simplified) <h3><?php echo $this->f_name; ?></h3> but like i said it only displays one forum(the last one).
-
thanks its working now. I just have to figure out how to display it in the correct way. eg: Category Forum Subforums - subforum forum2 forum3 Subforums - subforum2
-
ok i assumed that i was using the wrong fetch method. I am using PDO for my connection and was using PDO::FETCH_ALL. Ive changed it to PDO::FETCH_ASSOC and the $row array appears normal(no added numeric keys). So now: $cats: array(1) { [0]=> array(3) { ["f_fid"]=> string(1) "1" ["f_name"]=> string(7) "General" ["p_id"]=> string(1) "0" } } $forums: array(2) { [1]=> array(1) { [0]=> array(3) { ["f_fid"]=> string(1) "2" ["f_name"]=> string(10) "Discussion" ["p_id"]=> string(1) "1" } } [2]=> array(1) { [0]=> array(3) { ["f_fid"]=> string(1) "3" ["f_name"]=> string(9) "Sub Forum" ["p_id"]=> string(1) "2" } } } but when i echo $nforums it shows that the forum "discussion" has no subforums. yet as you can see by the previous image it has 1 subforum array(1) { [0]=> array(2) { [0]=> array(3) { ["f_fid"]=> string(1) "1" ["f_name"]=> string(7) "General" ["p_id"]=> string(1) "0" } [1]=> array(1) { [0]=> array(4) { ["f_fid"]=> string(1) "2" ["f_name"]=> string(10) "Discussion" ["p_id"]=> string(1) "1" ["subforums"]=> NULL } } } }
-
A dump of $cats: array(1) { [0]=> array(3) { [0]=> array(6) { ["f_fid"]=> string(1) "2" [0]=> string(1) "2" ["f_name"]=> string(10) "Discussion" [1]=> string(10) "Discussion" ["p_id"]=> string(1) "1" [2]=> string(1) "1" } [1]=> array(6) { ["f_fid"]=> string(1) "1" [0]=> string(1) "1" ["f_name"]=> string(7) "General" [1]=> string(7) "General" ["p_id"]=> string(1) "0" [2]=> string(1) "0" } [2]=> array(6) { ["f_fid"]=> string(1) "3" [0]=> string(1) "3" ["f_name"]=> string(9) "Sub Forum" [1]=> string(9) "Sub Forum" ["p_id"]=> string(1) "2" [2]=> string(1) "2" } } } but $forums returns empty
-
for reference here is my database layout: [attachment deleted by admin]
-
tested this and it works. Remove the border style from the element and add it to the css. <style type="text/css"> .button { border: none; } .button:hover { border-bottom:1px solid #000; } </style> <input type="submit" style="text-align:left; color:#0000FF;" class="button" value="Go to new window" onClick="OpenWin1();">
-
thanks for your reply. i have included your code but when i var dump $nforums it returns an empty array: $cats = $forums = $nforums = array(); $this_forums = array(); $query = $link->query("SELECT f_fid, f_name, p_id FROM ".TBL_PREFIX."forums"); while($row = $query->fetchAll()) { if($row['p_id'] == 0) { // these are root categories $cats[] = $row; } else { // these are all children, included sub-sub children, even sub-sub-sub children. $forums[$row['p_id']][] = $row; } } if(is_array($cats)) { foreach($cats as $cat) { if(is_array($forums[$cat['f_fid']])) { foreach($forums[$cat['f_fid']] as $forum) { // all of your forums children are loaded here. // you can even loop the sub forums and find the 4th node children $forum['subforums'] = $forums[$forum['fid']]; // Need to store this into the classes variable to be used globally. // View will later be decided on if there is a forum id set. $this_forums[] = $forum; } } } if(!empty($this_forums)) { $nforums[] = array($cat,$this_forums); } } var_dump($nforums); have i gone wrong somewhere?
-
try this: <style type="text/css"> .button:hover { text-decoration:underline; /* if above doesnt work try: border-bottom:1px solid #000; */ } </style> <input type="submit" style="text-align:left; border: none; color:#0000FF;" class="button" value="Go to new window" onClick="OpenWin1();">
-
*a shameful bump*
-
thanks for the support lads. This time ive been doing research and planning more and before i get into it again i need to clean up the code. I have also been looking at several other forums(not just phpbb and mybb) but other smaller forums and noticed that very few of them have a subforum feature where forums can be within forums. So that it my next step. To try and get it working. If you have time i made a post abut what help i need for this feature here. Id appreciate it if someone could take a look. Thanks.
-
thanks for the reply zac, i have decided to slowly give it another shot. I didnt realise how many people knew about ASF. Im not in this to be competing with other forums(not yet anyway) and only started this as a training thing. but keeping away from this has proven harder than i thought and with time(and patience) i know i can make it work. As far as helping goes, even people having a look at the forum once in a while and letting me know what they think is good it itself. Atleast if i know people are interested and following it will give me the motivation to keep at it. Thanks
-
ive decided to go with a simpler version to the MPTT algorithm. I have 2 database table. Categories and forums. categories c_cid c_name 1 first category forums f_fid c_id p_id f_name 1 1 0 forum --- this is a forum within category 1 2 1 1 subforum --- this is a subforum of forum within category 1 i am trying to display the name of any subforums under the forum name they belong to but with this code its only showing the subforums under the last forum displayed(which has no subforums). i think its something to do with the foreach loop as when i stick a var dump in there of the subforum list the list is only built when it gets to the bottom. $s_list = $pids = $fids = array(); $template->has_child = false; $query = $link->query("SELECT c.*, f.* FROM ".TBL_PREFIX."categories c LEFT JOIN ".TBL_PREFIX."forums f ON (f.c_id = c.c_cid) ORDER BY f.p_id ASC"); $row = $query->fetchAll(); foreach($row as $key => $value) { $forum_id = $row[$key]['f_fid']; $parent_id = $row[$key]['p_id']; for($i=0; $i<count($row); $i++) { $fids[] = $row[$i]['f_fid']; $pids[] = $row[$i]['p_id']; } if($row[$key]['p_id'] != 0) { $s_list[] = $row[$key]['f_name']; $template->is_child = true; } if($row[$key]['p_id'] == 0) { if(in_array($forum_id, $pids)) { $template->has_child = true; } else { $template->has_child = false; } $template->f_name = $row[$key]['f_name']; $template->description = $row[$key]['f_description']; $template->children = implode(', ', $s_list); } $template->fid = $row[$key]['f_fid']; $template->cat_name = $row[$key]['c_name']; $template->render($template->template.'templates/forum_list_tpl.php'); } anyone know why it will only display this list at the bottom and not under the correct forum?
-
since i am regretting this deletion i decided to see if i could find a way to retrieve the deleted files. fortunatly github allows you to see the files from previous commits so i now have the files back(minus the few config files). now i face the conundrum. Should i continue with ASF? if i do then im going to need help with it. It proved too much work for just one person to do. Look at phpbb or mybb, they have a team of staff developing it and a huge following. So without help and support i cannot continue with this. That being said, who is willing to help or support this project? I thought i could just give it up but that was easier said than done. if i get support and help then i guarantee i will see this project through to the end. Thats one of the reasons i gave it up, because i was doing it by myself with minimum support from people. *support = testing, bug finding, coding, the occasional compliment lol. Thanks for your time.
-
How can I limit the # of results displayed from a recordset?
doddsey_65 replied to MartinMar52011's topic in PHP Coding Help
that will teach me to read the post and not just the subject. now that i have read the post then yes please share some of your php code. also share what you have tried in this process. -
How can I limit the # of results displayed from a recordset?
doddsey_65 replied to MartinMar52011's topic in PHP Coding Help
in your query add to the bottom of it LIMIT followed by your limit: LIMIT 1 -
well i partly regret doing so but i couldnt go any further without solving the problems it had. And i couldnt find the help. It proved too much for one man to do alone lol. Thanks for the replies. I didnt know people were actually following ASF.
-
Looking for a better way to insert values into database
doddsey_65 replied to perky416's topic in PHP Coding Help
sorry, my bad hes right -
I have decided to discontinue working on ASF and as such have deleted all files regarding it. It has taken far too long to get to this stage and when you can't make an attachment system then theres no hope for the rest of the project. Thanks for the help and support but ASF will not be coming back. The git hub repo has been emptied as have the files on the server and my local server.
-
Looking for a better way to insert values into database
doddsey_65 replied to perky416's topic in PHP Coding Help
example for above: $error = array(); if (!$first_name) { $error[] = "Please enter your first name!"; } if(empty($error)) { // code to write to database here } else { echo explode('<br />', $error); } -
can you make an sql every X seconds with php?
doddsey_65 replied to gibigbig's topic in PHP Coding Help
on my site to check if a user has an email i query the database in a file called initilize.php which is called by header.php, which is called by every file. This means that every time the page is reloaded this query runs to check if there are new emails. maybe try something along those lines. -
i still cant get it to work, it just displays the same name for both attachments. <?php $query = $link->query("SELECT p.*, u.u_username, u.u_posts, u.u_avatar, u.u_signature, u.u_avatar_cropped, group_concat(a.a_name) as name FROM ".TBL_PREFIX."posts as p JOIN ".TBL_PREFIX."users as u ON (u.u_username = p.p_poster) LEFT JOIN ".TBL_PREFIX."post_attachments as a ON (p.p_pid = a.a_pid) WHERE p.p_tid = '$tid' GROUP BY p.p_pid ORDER BY p.p_time_posted ASC")or die(print_link_error()); $row = $query->fetchAll(); foreach($row as $key => $value) { $p_content = str_replace('<br>', '', $row[$key]['p_content']); $name = preg_split('|,|', $row[$key]['name']); for($i=0; $i<count($name); $i++) { $bb[$key] = "#\[attachment=(.*?)\]#si"; $html[$key] = $name[$i]; } $p_content = preg_replace($bb[$key], $html[$key], $p_content); echo $p_content; ?> $p_content has to be in the foreach loop as there may be more than one post within this topic.
-
this query is to show a forum post and any attachments belonging to that post. lets just say there is one record in the asf_posts table p_pid | p_tid | p_name | p_content | p_author 1 5 post this is the content doddsey65 so i pull all of the data from asf_posts where the p_tid = the current topic id. i then need to grab some info for the user that made the post so i can display their signature and avatar. So i join asf_users u_uid | u_username | u_avatar | u_sig 3 doddsey65 image this is my sig but i also want to get all attachments from asf_post_attachments where a_pid = the current post id for which there are 2 a_aid | a_pid | a_name 1 1 attachment 2 1 attachment2 now if the post has an attachment then the content of the post will be like so this is the content [attachment=attachment.jpg] [attachment=attachment2.jpg] so i do some regex and replace the bbcode with the name of the attachment. I know i can just use \\1 but im testing this because the attachment size will be pulled from the database also. so the bbcode will be replaced with <div> attachment name </div> and a new div will be created for each attachment with each attachments name within it <div> attachment name2 </div> here is my code: <?php $query = $link->query("SELECT p.*, u.u_username, u.u_posts, u.u_avatar, u.u_signature, u.u_avatar_cropped, group_concat(a.a_name) attachments FROM ".TBL_PREFIX."posts as p JOIN ".TBL_PREFIX."users as u ON (u.u_username = p.p_poster) LEFT JOIN ".TBL_PREFIX."post_attachments as a ON (p.p_pid = a.a_pid) WHERE p.p_tid = '$tid' GROUP BY p.p_pid ORDER BY p.p_time_posted ASC")or die(print_link_error()); $row = $query->fetchAll(); $title = array(); foreach($row as $key => $value) { $p_content = str_replace('<br>', '', $row[$key]['p_content']); $title[] = $row[$key]['attachments']; $bb[$key] = "#\[attachment=(.*?)\]#si"; $html[$key] = '<div>'.$title[$key].'</div>'; $p_content = preg_replace($bb[$key], $html[$key], $p_content); } ?> but as i said it displays the name of each attachment in both divs. any clearer?