PDA

View Full Version : PHP Assistance



Euphonick
14-05-2005, 11:37 PM
Hello,
I am working on a Webring for my website and I am having problems with the coding.

I am working on the links to change between previous and next site, it currently just reloads the current page so I need your help.

Here is my code:

include('config.php');

$id2 = $_GET['id'];
$id = $id2 - 1;
$output = mysql_query("SELECT * FROM webring WHERE id='$id'") or die();

while ($row=mysql_fetch_array($output)) {
$nextsite = $r['site_url'];
}
echo "<meta http-equiv=\"refresh\" content=\"0; url=$nextsite\" />\n";

It looks fine to me, but it obviously isn't so if anyone can help please do.
Thanks
Nick

Mentor
14-05-2005, 11:43 PM
so, so where does it get $_GET['id']

Plus if your using numbers

say site 1

then u call for site 0 ?

im not quite sure how its supposed to loop threw it "/

Euphonick
15-05-2005, 09:59 AM
Well it gets id from the url so it will be something like ?id=1 then it adds or takes one off that so it will change to 2 then it will use that id and get the url from the database and redirect to that url.

Mentor
15-05-2005, 11:25 AM
anyway.

I *think* it maybe that when u get the id to tsrat with, your pulling the one form the previos site, chnging it to - 2 would fix this if it were the case

Euphonick
15-05-2005, 01:24 PM
Well I managed to make it get the sites url from the database but now I can't get it to redirect to that url, if I use a meta redirect it just reloads the current page because it deosn't get the url and headers have allready been sent so I can't do a Header redirect.

Mentor
15-05-2005, 01:26 PM
shoulnt the php genirate before the meta refesh?

you could always use a javascript redirect?

Euphonick
15-05-2005, 01:49 PM
Javascript deosn't support php I don't think, I tried anyway because I need to use a variable for the site url.

Mentor
15-05-2005, 01:56 PM
php creats a html page. then javascript makes the users computer chnage the page rather, thatn php doing it behind the seans "/

php genirates all its stuff before anything is loaded to the uses computer, javaerscript, meta tags and all "/

Euphonick
15-05-2005, 02:00 PM
Well why won't the meta tag get the url? It just say's the variable in the html code so it has nothing to redirect to and just constantly reloads the current page.

I sorted it now, it deos redirect.
I am now working on making it go to 1 when your on the last site and go to the last site when your on 1.
Also doing the Random site which I know how to do, I am trying to get the ID for the last site in the database but i'm trying to use a loop but that deosn't seem to work.

splintercell!
15-05-2005, 05:07 PM
have you given the sites id's ???

Euphonick
15-05-2005, 08:25 PM
Yes I have done all that.

Want to hide these adverts? Register an account for free!