Jump to content

doddsey_65

Members
  • Posts

    902
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by doddsey_65

  1. Trying to make it simpler: Basically i could create three extra database tables for child forums, child topics and child posts. But i dont want this. It is alot more work and it can get very confusing. What i want is something like an extra column of two in the forum table. Like child_id and forum type. Where child id stays at 0 if its not a child and forum type is 'f'. But if it is a child then child id is the id and forum type is 'c'. Then in the code which displays the topics within the forum i need to display all of the topics but i also need to display the child boards within that forum. So something like: if ($forum_type == 'c') { loop through the records for all child boards with the forum id of the forum } it sounds simple enough but im struggling, especially when i have to work it into my existing code. attached is a copy of topics.php which displays all the topics once someone clicks on a forum. I also added an sql dump of the tables needed to make this page work incase you want to test it. [attachment deleted by admin]
  2. I wil ltry and explain this the best i can so please bare with me if it doesnt come out right first time lol. I am making a forum and as we all know forums have subforums or child boards that are within the forums themselves. Like php freaks has the forum php coding and then a sub forum within it for php regex. Im having trouble coding this though. Anyone have any tips on code and database structure that could help? I was thinking of making three new database tables for child forums, child topics and child posts but im sure there is an easier way. something like a column within the main forum table which defines wether the forum is a child or not. But then how would i link this child forum with the forum that its supposed to be in. Any advice is greatly appreciated. Thanks.
  3. You need to include \'s echo "Title:<br>"; echo "<input type=\"text\" name=\"title\" value=\"{$row['Title']}\" />";
  4. onclick="return confirm(\'You are being redirected to \\1. Proceed?\') That is a javascript alert box with confirm/cancel properties
  5. thats what i am after and i did try it but the popup just echos \\1 it doesnt print the actual url
  6. What I mean is $YOUR_VARIABLE_INSIDE_HERE needs to be the url they are clicking. The href. Eg/ $replace='<a href="\\1" onclick="return confirm(\'You are being redirected to '.$YOUR_VARIABLE_INSIDE_HERE.'\'));">link</a>';
  7. thanks for the info. But how would i add the url into a variable so i could call it in the popup box?
  8. Im having trouble deleting the selected checkboxes in my form. I have tried several options out there but none seem to work. here is the code i have which generates the checkboxes. i am alos using jquery to select all. <form name="checkboxes" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> This is within the while loop: echo "<input value=\"{$messages_info->message_id}\" style=\"float:left;\" type=\"checkbox\" name=\"checkbox\" />"; <a href="<?php echo $site_root; ?>/user_center.php?user=<?php echo $_GET['user']; ?>&do=messages&action=del_marked"> Delete Marked</a> </span> Anyone have any ideas? Thanks
  9. basically what i am trying to do is replace the <a href="whatever.com"> with <a href="whatever.com" onclick = "if (! confirm("Continue?")) return false;"> so that when the user clicks the url in a message the box pops up first then redirects them to the url if they click confirm. However i am getting the following error: Warning: preg_replace() [function.preg-replace]: Compilation failed: reference to non-existent subpattern at offset 11 here is the code i used. $message_content = $content_info['message_content']; $pattern='<a href="\\1">'; $replace='<a href="\\1" onclick = "if (! confirm("Continue?")) return false;">'; $message_content = preg_replace($pattern, $replace, $message_content); echo $message_content; Anyone know where i went wrong?
  10. thanks twitch. I did in the end use jquery. I did find some scripts that did it for me but jquery was the better choice. I do have an offtopic question regarding your code though. at the beginning you add: $detail=$_POST["id"]; $detail = mysql_real_escape_string($detail); but i would use: $detail = mysql_real_escape_string($_POST["id"]); is there any difference? I dont think there would be but you never know. Also where you use: $query = "SELECT * FROM your_table WHERE id = '$detail'"; $qry_result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($qry_result)){ i would use: $query = mysql_query("SELECT * FROM your_table WHERE id = '$detail'") or die(mysql_error()); while($row = mysql_fetch_array($query )){ Like i said just interested to know if there is any difference. Thanks
  11. i am making a private messaging system like hotmails where the message list appears on the left. Then when you click on one of them the box on the right loads the email. The problem is i dont really know how to go about it. Anyone have any pointers?
  12. thanks for the reply, i didnt know i could join the same table twice. Ill try it now.
  13. Okay so I have 2 forums, which each have 1 topic and atleast 1 post within those topics lets call them forum 1 and forum 2 where the number is the id in the database under forum_id they are in a parent with a parent id of 1 so the database layout is forum_id - forum_parent_id 1 1 2 1 but i want to add a child board/subforum to forum_id 1. So i added two more columns forum_type f for forum or c for child board forum_connection the forum id this child is in(if its a child) but how would i get forum child with a forum_connection of 1 to appear under the forum with an id of one? here is my query: $query = $db->query("SELECT f.forum_id, f.forum_name, f.forum_description, f.forum_topics, f.forum_posts, f.forum_type, forum_connection, f.forum_last_poster, f.forum_last_post_time, f.forum_last_post, p.parent_id, p.parent_name, m.user_id, m.user_username, m.user_group, t.thread_topic_id, t.topic_name FROM forum_parents as p JOIN forum_forums as f ON f.parent_id = p.parent_id LEFT JOIN forum_members as m ON f.forum_last_poster = m.user_username LEFT JOIN forum_topics as t ON t.topic_name = f.forum_last_post WHERE f.forum_type = 'f' ORDER BY p.parent_id, f.forum_id ASC") or trigger_error("SQL", E_USER_ERROR); hopefully someone will understand this lol
  14. thanks it works perfectly now there isnt a time format to display without leading 0's so i used your code.
  15. PDO::PARAM_STR ); that bracket shouldnt be there im thinking, but without a look at the full code i cant be sure
  16. thanks for the advice, i got it working before i read your post anti-moronic but a slight issue. when the post was made less than 30 minutes ago it shows how many minutes ago it was made. but it has a leading 0 eg 05 minutes ago. how would i replace that 0 or remove it? my code: $last_post = strtotime($topic_info->topic_last_post_time); $today = strtotime('NOW'); $last_post_gap = $today - $last_post; $last_post_gap = date('i',($last_post_gap)); $min = strtotime('- 1 MINUTE'); $normal = strtotime('- 30 MINUTES'); if ($last_post <= $normal) { echo '<p class="last_post_date">'.date('F j, Y g:i a', strtotime($topic_info->topic_last_post_time)); } elseif ($last_post >= $min) { echo '<p class="last_post_date">Less Than 1 Minute Ago'; } else { echo "<p class=\"last_post_date\">{$last_post_gap} minutes ago"; }
  17. why not is test0.php use: <html> <head> </head> <body> <?php include ('test.php'); ?> <img src="$image; ?>"/> </body> </html>
  18. im no expert but from the looks of your code you are assuming that i will know the page number. But thats my problem because when its inserted into the database i wont know which page number it is on to redirect to. I could use several if statements but surely theres a better way.
  19. I am using a header redirect after a user makes a post which goes to their post. example they made a post which has an id of 236, then the url redirect would be index.php?forum=1&topic=1&post=236#p236 i have the <a name> set up on each post and it works fine until the post is on a different page. the url should be: index.php?forum=1&topic=1&page=2&post=236#p236 but how would i be able to tell the header redirect which page to go to. I was thinking if statements like: if ($number_of_results >=10) { $page = 2; } but that would involve alot of if statements with no way of knowing how many pages the topic could have. Is there an easier way?
  20. that sounds a bit complicated. Any tips? Here is the code for the textarea and preview box: <textarea class="test" id="reply" name="test" style="height:350px;width:785px;"></textarea> <script type="text/javascript"> $("textarea").keyup(function () { var value = $(this).val(); $("#preview").text(value); }).keyup(); </script> <p id="preview"> Your Preview will appear here </p> And here is some of the bbcode parser: class bbParser{ public function __construct(){} public function getHtml($str){ $bb[] = "#\[b\](.*?)\[/b\]#si"; $html[] = "<b>\\1</b>"; $bb[] = "#\[i\](.*?)\[/i\]#si"; $html[] = "<i>\\1</i>"; $bb[] = "#\[u\](.*?)\[/u\]#si"; $html[] = "<u>\\1</u>"; $str = preg_replace ($bb, $html, $str); return $str; } } you can see it here: http://thevault.cz.cc/new_post.php?forum=1&topic=65 You will need to login with username:public and password:public then click Post reply at the bottom left.
  21. basically when a user enters something into textarea the content of the text area is added to the <p> as you type. but when you click a bbcode button(lets say Bold) the content of the text area will be [bold]the word[/bold]. But then the preview box will also look the same because its generated using jquerys .val(). <script type="text/javascript"> $("textarea").keyup(function () { var value = $(this).val(); $("#preview").text(value); }).keyup(); </script> so how would i be able to format $("#preview").text(value); with my bbparser?
  22. i have some code which displays text area contents in a preview box using jquery. but this is for a forum which means the text area will contain something like word. This will just print the . I know i can replace that with str_replace but that means the contents of the textarea need to be in a variable. so how do i add it into a variable? <script type="text/javascript"> $("textarea").keyup(function () { var value = $(this).val(); $("#preview").text(value); }).keyup(); </script> <p id="preview"> Your Preview will appear here </p>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.