收录日期:2020/12/03 00:14:59 时间:2010-09-07 20:44:55 标签:php,string,constants

I am using a constant NEWS_POST_NUMBER and i am getting confused on how to attach it to a string to query it to database. i tried many things and it is giving errors.

here is the string i tried.

$query = "
SELECT news.id, news.timestamp, news.title 
FROM news 
ORDER BY id DESC 
LIMIT $from, NEWS_POST_NUMBER";

please note NEWS_POST_NUMBER is the constant i have defined i want to attach it to query how do i do it?

$query = "
SELECT news.id, news.timestamp, news.title 
FROM news 
ORDER BY id DESC 
LIMIT $from, " . NEWS_POST_NUMBER;
$query = "SELECT news.id, news.timestamp, news.title FROM news ORDER BY id DESC LIMIT $from, " . NEWS_POST_NUMBER;

Use the concatenation operator ;)