marklarah Posted January 21, 2008 Share Posted January 21, 2008 Okay, so i've made some basic forums (features for lock, delete and such) but the one thing I need it to have is a sticky feature. Any ideas on how to work that into this code? This is my genmessage.php: <?php include_once 'top.php'; ?> <html> <title>TLS-3 Foums</title> <body bgcolor="#000000"> <p>Hi</p> <table width="900" align="center" border="0"> <tr> <td width="100%" height="133"> <img src="top.gif" width="900" height="133"></td> </tr> <tr> <td width="100%" height="30" bgcolor="#333333"> <font color="#FFFFFF" face="Bell MT, Bahtang, Helvetica"><? include 'bar.php'; ?></font> </td> </tr> <tr> <td width="100%" bgcolor="555565"> <?php include 'dbs.php'; ?> <font face="Arial, Helvetica"><h1>Messages <hr width="300" color="white" align="left"></h1><h2> <?php if (isset($_GET['board'])) { $boardA = $_GET['board']; $lool = 'SELECT * FROM boards WHERE `ID` = '.$boardA; $lol = mysql_query($lool) or die(mysql_error()); $row = mysql_fetch_array($lol); $tit = $row['title']; echo '<table><tr><tr>'; echo $tit; echo '</td><td>'; } ?> </h2><h3> <?php if (isset($_GET['topic'])) { $boardB = $_GET['topic']; $loolo = 'SELECT * FROM topics WHERE ID = '.$boardB; $lolo = mysql_query($loolo) or die(mysql_error()); $rowob = mysql_fetch_assoc($lolo); $titler = $rowob['Name']; echo $titler; echo '</td></tr></table>'; } ?> </h3></font><font face="Century Gothic, Arial"> <? if (!isset($_GET['board']) || !isset($_GET['topic'])) { ?> You have to supply a valid board & topic ID to access this page. Return to the <a href="index">General Board List</a> to select a board. <?php exit; } if(!isset($usernamem)) { ?> You have to login/register this page. Return to the <a href="forum.php">General Board List</a> to select a board. <?php exit; } ?> <?php $board = $_GET['board']; $topic = $_GET['topic']; // ORDER BY time LIMIT 20 $resultbob='SELECT * FROM messages WHERE board = '.$board.' and topic = '.$topic.' ORDER BY time ASC'; $tarticles = mysql_query($resultbob) or die(mysql_error()); $tnum = mysql_num_rows($tarticles); $height = 140; ?> <table width="60%" align="center" border="1"> <tr><td bgcolor="black"><font color="white"><b><a href="newmessage.php?board=<?php echo $boardA; ?>&topic=<?php echo $boardB; ?>">Add new post</a></b> | <b><a href="gentopic.php?board=<?php echo $boardA; ?>">Back</a></b> <?php if ($_SESSION['lvl'] >= "50"){ $loolo = 'SELECT * FROM topics WHERE ID = '.$boardB; $lolo = mysql_query($loolo) or die(mysql_error()); $rowob = mysql_fetch_assoc($lolo); $titler = $rowob['oc']; if ($titler == 0){ echo ' | <a href="locktopic.php?board='.$boardA.'&topic='.$boardB.'">Lock Topic</a>'; }else{ echo ' | <a href="unlocktopic.php?board='.$boardA.'&topic='.$boardB.'">Unlock Topic</a>'; } echo ' | <a href="deltopic.php?board='.$boardA.'&topic='.$boardB.'">Delete Topic</a>'; } ?> </font></tr></td></table> <table width="98%" align="center" border="1"> <? $i = "0"; while ($tnum = mysql_fetch_assoc($tarticles)){ $i++; $userp = $tnum['username']; $dpost = $tnum['time']; $pid = $tnum['messageid']; $message = $tnum['message']; echo '<tr><td width="22%" align="center" bgcolor="#53868B"><u>'; echo $userp; echo '</u></td><td width="78%" align="left" bgcolor="#53868B">'; echo '<b>Date Posted: </b>'.$dpost; echo ' | #'.$i; if ($_SESSION['lvl'] >= "50"){ echo ' | <a href="delpost.php?board='.$boardA.'&topic='.$boardB.'&pid='.$pid.'"> Delete</a>'; } echo '</td></tr>'; echo '<tr><td width="22%" height="'.$height.'" valign="top" align="center" bgcolor="#53868B">'; // $userp = $rowl['username']; // $message = $rowl['message']; $qryp = mysql_query("SELECT * FROM `users` WHERE `username` = '$userp'"); $rowqp = mysql_fetch_array($qryp); $levelp = $rowqp['level']; $qrypr = mysql_query("SELECT * FROM `ranks` WHERE `number` = '$levelp'"); $rowqpr = mysql_fetch_array($qrypr); $rankp = $rowqpr['title']; echo '<b>'.$rankp.'</b><br>'; echo 'Level: '.$levelp; echo '</td><td wdth="78%" height="'.$height.'" valign="top" align="left" bgcolor="#5F9EA0">'; ?> <font size="-1"> <?php echo $message; ?> </font> <?php echo '</td></tr>'; } ?><br><br><table width="60%" align="center" border="1"> <tr><td bgcolor="black"><font color="white"><b><a href="newmessage.php?board=<?php echo $boardA; ?>&topic=<?php echo $boardB; ?>">Add new post</a></b> | <b><a href="gentopic.php?board=<?php echo $boardA; ?>">Back</a></b></font></tr></td></table> </table> </font> any ideas welcome Quote Link to comment https://forums.phpfreaks.com/topic/87079-solved-how-to-make-a-sticky-feature/ Share on other sites More sharing options...
marklarah Posted January 21, 2008 Author Share Posted January 21, 2008 CANCEL LAST POST ________________ Okay, so i've made some basic forums (features for lock, delete and such) but the one thing I need it to have is a sticky feature. Any ideas on how to work that into this code? This is my gentopic.php: <?php include_once 'top.php'; ?> <html> <title>TLS-3 Foums</title> <body bgcolor="#000000"> <p>Hi</p> <table width="900" align="center" border="0"> <tr> <td width="100%" height="133"> <img src="top.gif" width="900" height="133"></td> </tr> <tr> <td width="100%" height="30" bgcolor="#333333"> <font color="#FFFFFF" face="Bell MT, Bahtang, Helvetica"><? include 'bar.php'; ?></font> </td> </tr> <tr> <td width="100%" bgcolor="555565"> <?php include 'dbs.php'; ?> <font face="Arial, Helvetica"><h1>Topics <hr width="300" color="white" align="left"></h1><h2> <?php if (isset($_GET['board'])) { $boardA = $_GET['board']; $lool = 'SELECT * FROM boards WHERE `ID` = '.$boardA; $lol = mysql_query($lool) or die(mysql_error()); $row = mysql_fetch_array($lol); $tit = $row['title']; echo $tit; } ?> </h2></font><br><br> <?php // // A BIG thanks to jeffery and ZF and AF or the idea for the code. // if (!isset($_GET['board'])) { ?> You have to supply a valid board ID to access this page. Return to the <a href="forum.php">General Board List</a> to select a board. <?php exit; } if(!isset($usernamem)) { ?> You have to login/register this page. Return to the <a href="forum.php">General Board List</a> to select a board. <?php exit; } ?> <?php $board = $_GET['board']; // The query just below is the one Im hoping to get working, for the meanwhile, Im just trying to get the loop working. /* $result = mysql_query('SELECT Name, By, Last_Post, Board FROM topics WHERE board = '.$board.' ORDER BY Last_Post'); */ $onelol = "1"; /* $result = mysql_query("SELECT Name, CBy, Last_Post, Board FROM topics WHERE Board = '.$onelol.' ORDER BY Last_Post"); */ // $row = mysql_fetch_row($result); $result='SELECT ID, Name, CBy, Last_Post, Board FROM topics WHERE Board = '.$board.' ORDER BY Last_Post DESC'; $farticles = mysql_query($result) or die(mysql_error()); $fnum = mysql_num_rows($farticles); // $numrows=mysql_num_rows($result); ?> <table width="60%" align="center" border="1"> <tr><td bgcolor="black"><font color="white"><b><a href="newtopic.php?board=<?php echo $boardA; ?>">Add new topic</a></b> | <b><a href="forum.php">Back</a></b></font></tr></td></table> <br> <table width="100%"><tr width="100%" bgcolor="skyblue"><td width="60%"><b>Topic</b></td><td width="20%"><b>Created By</b></td><td width="20%"><b>Last Post</b></td></tr></table><hr> <table width="100%" border="1" bordercolor="white"> <?php while($row = mysql_fetch_array($farticles)) { $name = $row['Name']; $by = $row['CBy']; $last_post = $row['Last_Post']; $tid = $row['ID']; echo '<tr> <td width="60%"><a href="genmessage.php?board='.$board.'&topic='.$tid.'">'; echo $name; echo '</a></td> <td width="20%">'.$by.'</td> <td width="20%">'.$last_post.'</td> </tr>'; } ?> </table> <br> <table width="60%" align="center" border="1"> <tr><td bgcolor="black"><font color="white"><b><a href="newtopic.php?board=<?php echo $boardA; ?>">Add new topic</a></b> | <b><a href="forum.php">Back</a></b></font></tr></td></table> </td> </tr> </table> <?php include 'footer.php'; ?> </body </html> any ideas welcome edit: had wrong page code in this post, fixed now Quote Link to comment https://forums.phpfreaks.com/topic/87079-solved-how-to-make-a-sticky-feature/#findComment-445363 Share on other sites More sharing options...
PHP Monkeh Posted January 21, 2008 Share Posted January 21, 2008 This isn't an example to be put in to your code but just an idea. Have another field in your topics table called "sticky" or such, and treat it as a boolean. Then do 2 queries on the topics page, one at the top which will just get all topics where sticky = 1, and then your normal topic posts under it (where sticky = 0). You can use this process for announcements too Quote Link to comment https://forums.phpfreaks.com/topic/87079-solved-how-to-make-a-sticky-feature/#findComment-445365 Share on other sites More sharing options...
marklarah Posted January 21, 2008 Author Share Posted January 21, 2008 V good idea thanks Quote Link to comment https://forums.phpfreaks.com/topic/87079-solved-how-to-make-a-sticky-feature/#findComment-445388 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.