Jump to content

SQL Select From: Display 1 result


Username:

Recommended Posts

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

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");

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.