PHP - Bolded Topics
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"; } 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. 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. 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 |