[Free] Content based on URL... not really sure how to describe this.

Started by MoreBloodWine, February 11, 2015, 08:23:10 PM

Previous topic - Next topic

MoreBloodWine

index.php?page=lottery

Ok, that so that's a page address of one of my sites. I'd like to do something like this which I know is possible but don't recall how since it's been years since I've required this kind of set up.

I would like to do something like this, based on the URL.

This: index.php?page=lottery&players=current

Displays: Content A

AND

This: index.php?page=lottery&players=previous

Displays: Content B

all the while...

This: index.php?page=lottery

Displays: Original Content

-------

So can anyone help me out here, Ty in advance.

Edit: Would like this done in PHP vs something like JS.

Ty.
Want a sig like mine for your BTCGuild stats ? Then check this out: Spend-ur-Bits


MoreBloodWine

I can't seem to edit my post hence the new reply.

Anyway, this is what I'm trying to work with that doesn't seem to be working so it's not like I haven't tried, again, ty in advance for any help provided.

<?php

$players $_GET['players'];
if (isset($players == 'current')) {
echo "Test A";
}
elseif (isset($players == 'previous')) {
echo "Test B";
}
else {
echo "Test C";
}

?>
Want a sig like mine for your BTCGuild stats ? Then check this out: Spend-ur-Bits


margarett

Something like this, maybe?
if (!isset($_GET['lottery']))
return;

if (!isset($_GET['players']))
echo 'Test C';
elseif ($_GET['players'] == 'current')
echo 'Test A';
elseif ($_GET['players'] == 'previous')
echo 'Test B';
else
echo 'Test C'; //if a wrong "players" is entered, display the default action


Untested :P
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

MoreBloodWine

Quote from: margarett on February 12, 2015, 01:01:35 PM
Something like this, maybe?
if (!isset($_GET['lottery']))
return;

if (!isset($_GET['players']))
echo 'Test C';
elseif ($_GET['players'] == 'current')
echo 'Test A';
elseif ($_GET['players'] == 'previous')
echo 'Test B';
else
echo 'Test C'; //if a wrong "players" is entered, display the default action


Untested :P
Doesn't seem to be working.

Link: http://spend-ur-bits.com/index.php?page=lottery

Should Display: Test C

Link: http://spend-ur-bits.com/index.php?page=lottery&players=current

Should Display (Due to the addition of &players=current): Test A

Link: http://spend-ur-bits.com/index.php?page=lottery&players=previous

Should Display (Due to the addition of &players=previous): Test B
Want a sig like mine for your BTCGuild stats ? Then check this out: Spend-ur-Bits


margarett

Yeah, it's wrong. OK let me fix it ;)

edit: this works
<?php
if (!isset($_GET['page']))
return;
if (
$_GET['page'] != 'lottery')
return;

if (!isset(
$_GET['players']))
echo 'Test C';
elseif (
$_GET['players'] == 'current')
echo 'Test A';
elseif (
$_GET['players'] == 'previous')
echo 'Test B';
else
echo 'Test C'//if a wrong "players" is entered, display the default action
?>
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

MoreBloodWine

That works, but when I replace the "test" stuff with the physical code that's actually supposed to be used on the page(s) it goes back to not working. Instead of posting my "live" code here, could I please PM you to have a look at the code ?

Ty in advance.
Want a sig like mine for your BTCGuild stats ? Then check this out: Spend-ur-Bits


margarett

Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

MoreBloodWine

Quote from: margarett on February 12, 2015, 01:49:23 PM
Yeah, sure ;)
Ty, working on the PM now.

After I send it I will be MIA for a few hours as I have a job interview to get ready for.
Want a sig like mine for your BTCGuild stats ? Then check this out: Spend-ur-Bits


margarett

Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

hunkandrew

Its not a hard work when it comes to PHP language! I really appreciate that there are lots of experts available to help out newbies. appreciated!

MoreBloodWine

 We
Quote from: margarett on February 12, 2015, 02:18:29 PM
Replied.
Good luck in your job interview ;)
Thx, I think it went well.

If I get it I would be a driver for the local blind association workin ~10hrs a week to start. As for the PM, checkin that aftedr I hit post.
Want a sig like mine for your BTCGuild stats ? Then check this out: Spend-ur-Bits


MoreBloodWine

Marking as solved thx to Margarett's expertise.

Ty !

@Margarett, still curious if you have any final thoughts per my last PM.
Want a sig like mine for your BTCGuild stats ? Then check this out: Spend-ur-Bits


Advertisement: