Forum Topic: random redirection php

(140 views • 1 reply)

This topic is 1 page long.

<< < > >>
Questioning

cashuu

Reply To Post Reply & Quote

Posted at: 4/21/06 08:53 PM

cashuu EVIL LEVEL 13

Sign-Up: 09/26/02

Posts: 198

hello fellow geeks.
i am having a problem with doing random content. by this i mean you know them pages where its random.php or image.php?id=0 and when you go to them it takes you to image.php?id=42 or whatever the randomly selected database row is.

i think they have one in the portal
http://www.newground..om/portal/random.php

see what i mean.

how do i do this?


None

Pilot-Doofy

Reply To Post Reply & Quote

Posted at: 4/21/06 11:49 PM

Pilot-Doofy LIGHT LEVEL 37

Sign-Up: 09/13/03

Posts: 12,282

Do something similar to this.

# Make sure you have already established
# your MySQL connection and that you have
# already selected your database.

$getRand = mysql_query("SELECT id FROM portalEntries ORDER BY RAND() LIMIT 1");
# Get ID
$randEntry = @mysql_result($getRand, 0, 'id');

header('Location: entry.php?id=' . $randEntry);

holy jesus what are these goddamn animals


All times are Eastern Standard Time (GMT -5) | Current Time: 01:36 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!