Username: Posted October 21, 2010 Share Posted October 21, 2010 Okay so, I'm adding a reply feature to my text-board, and I'm wondering how I can select a single result from the DB I've tried this $board = mysql_real_escape_string($_GET['board']); $thread = mysql_real_escape_string($_GET['thread']); $result = mysql_query("SELECT subject, name, id, timestamp, body FROM $board LIMIT $thread,$thread"); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { printf("<div id='html1' style='background-color:#F0E0D6;border:solid 1px #800000;font-family:arial; font-size: 12px; padding:2px; margin:2px;'><font color='#CC1105'>%s </font><font color='#117743'>%s</font> <font color='#800000'>Post # %s - %s<br />%s<br /></div>", $row[0], $row[1], $row[2], $row[3], $row[4], $row[5], $row[6]); mysql_free_result($result); } ?> Kinda works but if I pu ?thread=56 then it would show thread 57, which in this example does not exist. Link to comment https://forums.phpfreaks.com/topic/216459-sql-select-from-display-1-result/ Share on other sites More sharing options...
Username: Posted October 21, 2010 Author Share Posted October 21, 2010 don't even think this is correct but it works $board = mysql_real_escape_string($_GET['board']); $thread = mysql_real_escape_string($_GET['thread']); $realresult = $thread--; $result = mysql_query("SELECT subject, name, $realresult, timestamp, body FROM $board LIMIT $thread,$thread"); Link to comment https://forums.phpfreaks.com/topic/216459-sql-select-from-display-1-result/#findComment-1124790 Share on other sites More sharing options...
Buddski Posted October 21, 2010 Share Posted October 21, 2010 Use a where clause in your SQL $result = mysql_query("SELECT subject, name, id, timestamp, body FROM $board WHERE id = '$thread'"); Link to comment https://forums.phpfreaks.com/topic/216459-sql-select-from-display-1-result/#findComment-1124791 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.