PHP - Forums - Topics Viewed
So, you know how on forums (including this one) the icon of a topic/forum will be greyed out if your account viewed that topic's latest post, regardless of which computer you viewed it on? How exactly does it store that?
I know that logically it would store it on the Database, but I'm curious as to the actual implementation. It seems to me that storing every single topic you viewed it and when would take up huge numbers of rows, even for a small number of people, like say 100. If you have a forum with 1000's of people, each viewing even 3 topics a day, you're record numbers would be huge, slowing down the database. And calling your last viewed time for each and ever topic? Wouldn't that slow down the code excecution heaps? If you have any input, I'd love to hear it. It's a question I've been wrestling with in the back of my mind for a few years now Similar Tutorialshi i am working on a project in which i have to retrieve the articles which are the most visited by the users. i have serched the internet but not find any useful code snippets. can any one guide me how to solve this problem. ok, so here is the basic concept I want, but it is not working, everything is bold when the database is set to 1 for $read........could you take a look and help?: Code: [Select] <?php include 'config.php'; include 'opendb.php'; // if no id is specified, list the available articles if(!isset($_GET['id'])) { $query = "SELECT * FROM messages WHERE recipient ='$name' order by date desc"; $result = mysql_query($query) or die('Error : ' . mysql_error()); // create the article list while($row = mysql_fetch_array($result, MYSQL_NUM)) { list($from1, $recipient, $title1, $content, $id, $date, $read) = $row; if ($read == $userid){ $content1 .= "<br /><br /> $from1</p>\r\n"; $content2 .= "<br /><br /> <a href=\"/message.php?id=$id\">$title1</a>\r\n"; }else { $content1 .= "<br /><br /> <strong>$from1</strong></p>\r\n"; $content2 .= "<br /><br /> <a href=\"/message.php?id=$id\">$title1</a>\r\n"; } Hi there! I'm still getting use to using multiple rows when ordering in SQL, but I have a question. How can I display topics that are stickied first, then display all the threads below ordered by lastpost? I tried: //thread details $query = mysql_query("SELECT `date`,`lock`,`sticky`,`status`,`title`,`username`,`id`,`lastposter`,`lastpost` FROM threads WHERE parent = '{$_GET['forum']}' ORDER BY lastpost, sticky DESC LIMIT $start,$per_page") or die(mysql_error()); And the stickies do show up first, but all the regular threads aren't showing ordered by laspost DESC. Why is that? :/ Lastpost = datetime I am almost done with my website and I will use this thread to post small enhancements that would make my website better.........so #1, I have a code that will display news topics, how can I redo this code so that the topics are in reverse order and so that the title will be in bold lettering until it is read? Code: [Select] <?php session_start(); // Must start session first thing /* Created By Adam Khoury @ www.flashbuilding.com -----------------------June 20, 2008----------------------- */ // Here we run a login check if (!isset($_SESSION['id'])) { echo 'Please <a href="login.php">log in</a> to access your account'; exit(); } //Connect to the database through our include include_once "connect_to_mysql.php"; // Place Session variable 'id' into local variable $userid = $_SESSION['id']; // Query member data from the database and ready it for display $sql = mysql_query("SELECT * FROM members WHERE userid='$userid' LIMIT 1"); while($row = mysql_fetch_array($sql)){ $name = $row["name"]; $phone = $row["phone"]; $username = $row["username"]; $address = $row["address"]; $city = $row["city"]; $state = $row["state"]; $zip = $row["zip"]; $cell = $row["cell"]; $email = $row["email"]; $accounttype = $row["accounttype"]; $rank = $row["rank"]; $badges = $row["badges"]; } ?> <?php include 'config1.php'; include 'opendb.php'; // if no id is specified, list the available articles if(!isset($_GET['id'])) { $self = $_SERVER['PHP_SELF']; $query = "SELECT id, title FROM news ORDER BY id"; $result = mysql_query($query) or die('Error : ' . mysql_error()); // create the article list $content = '<ol>'; while($row = mysql_fetch_array($result, MYSQL_NUM)) { list($id, $title) = $row; $content .= "<li><a href=\"$self?id=$id\">$title</a></li>\r\n"; } $content .= '</ol>'; $title = 'News'; } else { // get the article info from database $query = "SELECT title, content FROM news WHERE id=".$_GET['id']; $result = mysql_query($query) or die('Error : ' . mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $title = $row['title']; $content = $row['content']; } include 'closedb.php'; ?> Code: [Select] <table width="600" border="0" align="center" cellpadding="10" cellspacing="1" bgcolor="#336699"> <tr> <td bgcolor="#FFFFFF"> <h1 align="center"><?php echo $title; ?></h1> <?php echo $content; // when displaying an article show a link // to see the article list if(isset($_GET['id'])) { ?> <p> </p> <p align="center"><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Back to News</a></p> <?php } ?> so once this topic is resolved.......I will probably post another small topic to look at. im using the modified preorder tree traversal heirarchal system for my forum. (http://articles.sitepoint.com/article/hierarchical-data-database/2) basically where you store the left and right id to form relationships between forums like phpbb does. but im struggling to show subforums underneath their parents. eg: Code: [Select] forum id left id right id parent id 1 1 8 0 this is a category 2 2 7 1 this is a forum belonging to the category 3 3 6 1 this is a forum belonging to the category 4 4 5 2 this is a subforum belonging to forum 2 i can display all of the forums within their categories fine but cant think how to add the subforums underneath the forums that have them. has anyone got any advice? 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. Hi all , I'm a newbie in PHP coding and wondering how to do like that: ...forums / showthread.php? t = 10 in VBulletin forums. I created forums using PHP (and his pros ^^ ) but I gave for each new topic a new .php page. Thanks for all who'll help me to do, at least some keywords to look for. Nice Regards! How do forums check if you've read a post or not? Is it through cookies? i installed the most popular chat mod on smf forums called ajax chat. i am certain i did everything correctly. but when i try to test it i get a 403 on byethost. ive also had problems with phpbb this must mean that byethost must not allow ajax does anyone know of a server that will allow me to use this mod? Hi Guys, I have a script that shows the user of my shop what they have looked at. I was wondering if someone can tell me how I can limit this so it only lists 10 and no more. Here is the code: Code: [Select] if(RECENTVIEWED ==1) { if(isset($_COOKIE['jimbeam'])){ $productUrl = SITE_URL."ecom/index.php?action=ecom.pdetails&mode="; $productUrl = $this->libFunc->m_safeUrl($productUrl); foreach ($_COOKIE['jimbeam'] as $name => $value) { $this->obDb->query="SELECT vTitle FROM ".PRODUCTS." WHERE vSeoTitle = '".$value."'"; $rsProd = $this->obDb->fetchQuery(); $this->obTpl->set_var("TPL_VAR_PRODUCTTITLE",stripslashes($rsProd[0]->vTitle)); $this->obTpl->set_var("TPL_VAR_PRODUCTURL",$productUrl.$value); $this->obTpl->parse("recent_blk","TPL_RECENT_BLK",true); } $this->obTpl->parse("mainrecent_blk","TPL_MAINRECENT_BLK"); } } Thanks, Jordan am currently building the cart system of a product, now there is this part wherein, the non-logged-in OR logged-in user should also be able to see the items that he/she viewed, how to do that?., am not asking for code snippets , just give me some ideas/hints/strategies/tips that may help me get the big picture on how to do this thing and proceed coding. Hello everyone I wonder if you could help me. I want to create a function called <?php function mythings($what) Which would allow me to pass an ID number to, such as <?php mythings(5419); What I want to do with that function is store the ID numbers of the past 6 items I have viewed, but I want to store each item as a SESSION once it has been passed. So essentially I would end up with the following 6 SESSIONS <?php $_SESSION['item1']; $_SESSION['item2']; $_SESSION['item3']; $_SESSION['item4']; $_SESSION['item5']; $_SESSION['item6']; So the "item1" SESSION would be the latest item ID passed through the function But then if I then passed a new ID through the function, that new ID passed would then become $_SESSION['item1']; and the current SESSION $_SESSION['item1']; would become $_SESSION['item2']; and $_SESSION['item2']; would become $_SESSION['item3']; and so on. This means I can do a list such as <?php print "Item 1".$_SESSION['item1']."<br>"; print "Item 2".$_SESSION['item2']."<br>"; print "Item 3".$_SESSION['item3']."<br>"; print "Item 4".$_SESSION['item4']."<br>"; print "Item 5".$_SESSION['item5']."<br>"; print "Item 6".$_SESSION['item6']."<br>"; ?> Does that make much sense? Can anyone help. Thanks very much all John Hello all, Wondering if you can help me, I am wondering if it is possible to get PHP to show the last websites you viewed, just giving the names of the websites in a list. If so? is there any pointers someone can give me as to how to learn to achieve something like this..I'd really appreciate the help! I have asked this question in 3 different places but I get no answers lol. I hope to find some help here.
i want to only display user role for keymaster and moderator users.
I don't want every participant to have their role shown , only the keymaster and moderators are important enough to me to show their role next to their avatar. The following function code i found, and used... It worked but has some issues:
function role_show () { $displayed_user = bbp_get_reply_author_id() ; $role = bbp_get_user_role( $displayed_user); if ( bbp_is_user_keymaster($displayed_user) ||$role == 'bbp_moderator') $args['show_role'] = true ; else $args['show_role'] = false ; return $args ; } add_filter ('bbp_before_get_reply_author_link_parse_args', 'role_show' )Code Issues: On the Forums topic post lists, This code also removes the avatar from showing in the same cell section as the “last post by” . And it removes the “last post by” name in this same section. How can I fix this ? If needed, I could implement this code again and provide a link to the error so you can see. Thank you for any help. Side notes: Someone told me to try function role_show ($args) {As my first line , but it did not work. It resulted in the following screenshot : as Attached Files functions-picture.png 35.46KB 0 downloads Hi guys I found a nice script that removes all the work of writing individual embedding for a long list of video host, it works well and pretty easy to be tweaked even by non coders such as me. One problem seems to be that some host have that annoying autostart or autoplay feature when a person places a link to a forum. So if you have a forum page with multiple urls for videos that auto start or play feature drives you nuts. I have tried to tweak the code by adding a param name= and used the 0 token and the false alpha word, still no luck with vimeo, it continues to start as soon as it finishes loading. This code block shows the script file for vimeo, there are only two files in my includes to run this script so both must be tweaked with the changes, I use the nifty free PSPad editor to do this and have no trouble making any changes needed. My question is at what level can an option like disabling a feature take place, is this something that must be performed by the host or can this script actually take a param name= to disable it. Thanks for any input or advice, pointing to a good read is most welcome also. Code: [Select] if (($vimeo) && (strpos($message, 'www.vimeo.com/') !== false)){ $message = preg_replace('#<a class="postlink" href="http:\/\/www.vimeo.com\/(.*?)">(.*?)<\/a>#U', '<object type="application/x-shockwave-flash" style="width:400px;height:230px;" data="http://vimeo.com/moogaloop.swf?clip_id=$1&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=$1&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" /></object>', $message);} Hello people i have a system that takes people to generated pages from the database, the user has a field to input a video and others watching videos will get redirecting to tht video in time, what i want to know is how can i tell if a user viewed the page so to stop them getting redirected to it again by my random video query? The link always is video.php?id=blabla the id changes every refresh, so i can call that id to check if there on the page but how can i tell if they have been on it before. hey all, i have an issue, i have a directory site called hackingtoolz.tk and if you go to it, you will see a list of folders as it is just a directory the problem is how to i stop the banner from apearing in the directory. i have tried changing the chmod to 4000 and that just made the jpeg stay their and the banner screw up if you go to the site you will understand what i mean better hope you can help cheers nick This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=327636.0 This script ...
<?php echo "Your IP Address: <br/>"; print_r($_SERVER['REMOTE_ADDR']); ?>... prints: ::1I am looking to have the IP address from which the site is viewed printed on screen. What is the issue, here, with the script I have? I have been trying this on localhost and I am using XAMPP. <?php query_posts('meta_key=post_views_count&posts_per_page=3&orderby=meta_value_num& order=DESC'); if (have_posts()) : while (have_posts()) : the_post(); ?> <ul class="rpul"> <li> <div class="class="post-thumb wp-post-image" style=' '> <?php if ( has_post_thumbnail() ) : ?> <?php the_post_thumbnail('thumbnail') ?> <?php endif ?> </div><div class='cat-post-text'> <h1> <a href="<?php the_permalink(); ?>"><?php the_title(); ?>
|