Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
ghank
Forum Commoner
Posts: 35 Joined: Tue Apr 06, 2004 3:21 pm
Post
by ghank » Thu Apr 15, 2004 12:51 pm
I have a php script that sets a variable:
And it has an include statement like this:
And in the template file I have a RAND function which currently pulls 15 entries from mysql.
Code: Select all
$sql_query = "SELECT * FROM LINKS ORDER BY RAND() LIMIT 15";
Anybody know how to put the $links variable in place of the LIMIT 15? I want to be able to change the $links variable in the original php file to vary the amount of links displayed on the page. I am new to PHP and couldn't find the answer anywhere. Thanks in advance!
xisle
Forum Contributor
Posts: 249 Joined: Wed Jun 25, 2003 1:53 pm
Post
by xisle » Thu Apr 15, 2004 1:01 pm
LIMIT $links should work..
ghank
Forum Commoner
Posts: 35 Joined: Tue Apr 06, 2004 3:21 pm
Post
by ghank » Thu Apr 15, 2004 2:14 pm
Tried that and it produced zero results.
magicrobotmonkey
Forum Regular
Posts: 888 Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA
Post
by magicrobotmonkey » Thu Apr 15, 2004 2:16 pm
echo it before you submit it an see what it says
ghank
Forum Commoner
Posts: 35 Joined: Tue Apr 06, 2004 3:21 pm
Post
by ghank » Thu Apr 15, 2004 3:13 pm
I echoed it and it returned 15 so it captured the variable. It's just a matter of sticking in the string.
ghank
Forum Commoner
Posts: 35 Joined: Tue Apr 06, 2004 3:21 pm
Post
by ghank » Thu Apr 15, 2004 3:16 pm
Hey, it works now. I tried again and inserting $links for 15 did it. I could have sworn I tried that before. Anywho, thanks for the info guys!