
Ashoar
Members-
Posts
214 -
Joined
-
Last visited
Never
Everything posted by Ashoar
-
So would you still recommend against using 0?
-
Ok thank you for the links PFMaBiSmAd I will take a look through them.
-
Ah, so i could just include that into the head of each page?
-
Thank you Premiso. Could you go into a bit of detail. How this could be done?
-
Hello. I was just wondering if there is any sort of session function or command that could be added to the header (or any section of a php code) that would prevent a member from being logged out after being idle on a single page for a long time or closing the window without logging out.
-
Just knocking this back up to the first page.
-
Ok so this was posted originally a few days ago where i received a solution to the problem from Mark. Although this worked well i am in need of extending this to get more data, but withouth a certain JOIN element in the MYSQL query. What this code here does, is fetches all topics from a certain board. The topics are determined by the parentid='0', which means they are a thread and not a reply. What i now need to do is also get all replies for each board, which means i need to remove the parentid part of the query. I thought maybe i could add a second query to do this, but when i do so it just runs through the array and displays the same board over and over as well as the same topic count. Here is the code: $boards = mysql_query("SELECT f.forum_name, f.forum_desc, f.board, COUNT(p.post) AS threads, MAX(p.showtime) AS showtime, MAX(p.lastposter) AS lastposter FROM forums AS f LEFT JOIN post_reply AS p ON p.board=f.board AND p.parentid='0' GROUP BY f.forum_name, f.forum_desc, f.board ORDER BY f.forum_id asc") or die(mysql_error()); $boards2 = mysql_num_rows($boards); for($count = 1; $count <= $boards2; $count++) { $board = mysql_fetch_array($boards); So is there a way to change this around a bit so that i can get the replies, for each board as well as the posts? To get the replies it is the same but without parentid, but i cant take parentid out as it will then not show the posts.
-
Problem is fixed. Thanks for the help.
-
Mark, that is almost what i am looking for, except when using that i get the mysql error "Could not get threads".
-
I took a look, but i don't think any applies to this situation, that i can see. Just a note, i use the same method to display the thread posts and it works, just fine. $gettopic="SELECT * from post_reply where postid='$id'"; $gettopic2=mysql_query($gettopic) or die("Could not get topic"); $gettopic3=mysql_fetch_array($gettopic2); $postcount="SELECT * from Users where Username='$gettopic3[author]'"; $postcount2=mysql_query($postcount) or die("Could not get postcount"); $postcount3=mysql_fetch_array($postcount2); print "<tr class='mainrow'><td valign='top'><p><A href='member_profile.php?username=$gettopic3[author]'>$gettopic3[author]</a></p><p>Posts: $postcount3[postcount]</p></td><td valign='top'>Last replied to at $gettopic3[showtime]<br><hr>"; $message=strip_tags($gettopic3['post']); $message=nl2br($message); print "$message<hr><br>$postcount3[signature]<br>"; It seems to be this part in the replies section that is causing the problem: while($getreplies3=mysql_fetch_array($getreplies2)) The while statement, it is the only difference in from the above. But if i change it to a normal array it doesn't work.
-
Ah see i have no way of joining the 2 boards together like that. So is there no other method i could join these or even just solve the problem i posted above: "Basically what is happening here is that the postcount variables are grabbing the post count of the users who have replied and their signatures, so that i can output them in their post. Getreplies variables are grabbing all of the replies for the thread, which is determined by the postid in the query. But when i add these it does not show the post count and signatures. If i move the post count query's under the get replies query's it doesn't show the replies. I assumed it may be fixed my merging the query's together."
-
No i don't, i just have the author field, which holds the usernames of replies to a post. Basically what is happening here is that the postcount variables are grabbing the post count of the users who have replied and their signatures, so that i can output them in their post. Getreplies variables are grabbing all of the replies for the thread, which is determined by the postid in the query. But when i add these it does not show the post count and signatures. If i move the post count query's under the get replies query's it doesn't show the replies. I assumed it may be fixed my merging the query's together. Here is the rest of the code in case the problem is something else: $postcount0="SELECT * from Users where Username='$getreplies3[author]'"; $postcount02=mysql_query($postcount0) or die("Could not get postcount"); $postcount03=mysql_fetch_array($postcount02); $getreplies="Select * from post_reply where parentid='$id' order by postid asc"; $getreplies2=mysql_query($getreplies) or die("Could not get replies"); while($getreplies3=mysql_fetch_array($getreplies2)) { print "<tr class='mainrow'><td valign='top'><p><A href='member_profile.php?username=$getreplies3[author]'>$getreplies3[author]</a></p><p>Posts: $postcount03[postcount]</p></td><td valign='top'>Last replied to at $getreplies3[showtime]<br><hr>"; $message=strip_tags($getreplies3['reply']); $message=nl2br($message); print "$message<hr><br>$postcount03[signature]<br>"; print "</td></tr>"; }
-
I was just wondering if there is a way to join these 2 MYSQL query's into one. $postcount0="SELECT * from Users where Username='$getreplies3[author]'"; $postcount02=mysql_query($postcount0) or die("Could not get postcount"); $postcount03=mysql_fetch_array($postcount02); $getreplies="Select * from post_reply where parentid='$id' order by postid asc"; $getreplies2=mysql_query($getreplies) or die("Could not get replies"); while($getreplies3=mysql_fetch_array($getreplies2)) Thanks.
-
I just managed to fix the problem. Just re-did a few of the variables that get the page number and output it. Seems to have fixed it. Thanks for the help.
-
That fixed the link structure but there is still one problem. When clicking on the "Next Page" bit, it just load for a second and brings me back to the same page.
-
Ok i have the main part of it working now. Now there is a few problems. The link for the next page does not work correctly. It is linked like this: /board.php?board=test&page=2>></a> <a href = If i copy that into the address bar and remove those end bits it just directs me to the page i am already on. Here is this code: <?php include "config.php"; $forumid=$_GET[board]; print "<link rel='stylesheet' href='style.css' type='text/css'>"; print "<A href='post.php?board=$forumid'>New Topic</a><br>"; $page = 1; $size = 10; if (isset($_GET['page'])){ $page = (int) $_GET['page']; } print " <table class='maintable'> <tr class='headline'><td width=15%>Topic</td> <td width=5%>Author</td><td width=5%>Replies</td> <td width=20%>Last reply</td> </tr> "; $sql = "SELECT COUNT(*) FROM post_reply"; $result = mysql_query($sql) or die('No: '.$mysql_error()); list($numrows) = mysql_fetch_row($result); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 10; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; $info="SELECT * from post_reply WHERE board='$forumid' AND parentid='0' ORDER BY lastrepliedto DESC LIMIT $offset, $rowsperpage"; $info2=mysql_query($info) or die(mysql_error()); while($info3=mysql_fetch_array($info2)) { $info3[title]=strip_tags($info3[title]); $info3[author]=strip_tags($info3[author]); print " <tr class='mainrow'><td><A href='message.php?id=$info3[postid]'>$info3[title]</a></td> <td><center><A href='member_profile.php?username=$info3[author]'>$info3[author]</a></center></td> <td><center>$info3[numreplies]</center></td> <td>$info3[showtime]<br>Last post by <A href='member_profile.php?username=$info3[lastposter]'>$info3[lastposter]</a></td> </tr> "; } /****** build the pagination links ******/ // range of num links to show $range = 3; // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='board.php?board=$forumid&page=$nextpage>></a> "; // echo forward link for lastpage echo " <a href='board.php?board=$forumid&page=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ print "</table>"; ?>
-
"Fatal error: Function name must be a string in /home/public_html/forum/board.php on line 35"
-
Yes same script. It is the database query above what we just fixed.
-
Ah yes, that sorted that error out. Now the other error is still there: Fatal error: SQL in /home/public_html/forum/board.php on line 35
-
Yes, it contains all posts and replies made within the forum. It also has about 30 entries in it, so it isn't empty.
-
Ok this time only the 1 error was displayed: "Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource" And the part we just changed gave the output "No: " So it seems a MYSQL error on that part.
-
Sure did, also tried echoing lower in the page and after the array. All places still came back with the 2 errors.
-
Echo did not work, just continued to give the errors without echoing the query.
-
Tried to echo the query but i just get the same errors. Am i using the pagination correctly?
-
Yes, but that query worked perfectly fine until the pagination was added.