...

View Full Version : $get



TobyCS
05-04-2009, 08:57 PM
Hey :)

I am creating a website and using /index.php?page= to display my content. I have come to a stage where I need to show multiple things for one page but on seperate pages. For example /index.php?page=shows?dj=autodj then i would need another one for /index.php?page=shows?dj=djjohn for example. How can I go about doing this?

Here is my code:


<?php
if(file_exists($_GET['page'].".php"))
include ($_GET['page'].".php");
else include("main.php");
?>


Also can you tell me why this more secure one won't work?



<?php
if(isset($_GET['page'])) {
if(file_exists('pages/'.$_GET['page'].'.php')) {
include('pages/'.$_GET['page'].'.php');
}
else {
echo('Page not found.');
exit;
}
else {
include('pages/main.php');
}
?>

CalumK
05-04-2009, 09:04 PM
simple!

in your url


/index.php?page=shows?dj=autodj
change to


/index.php?page=shows&dj=autodj

for multiple Gets just use ? the first time and & for each one after!


For your second question, i believe you are missing a closing }
try adding one more at the end!

TobyCS
05-04-2009, 09:11 PM
I understand that but where do I assign the &dj=autodj because I don't want it to include it on every page.

Fumigator
05-04-2009, 09:55 PM
Are your pages in a directory called pages or not? The first snippet assumes no, the second snippet assumes yes.

Your other question is a bit confusing: You want one page to come up for both DJs but then you say you want separate pages. Which one is it?

2Pacalypse
05-04-2009, 10:01 PM
Well... I done my pages pretty different...



<?php
switch($_GET['item'])
{
case 'sig1': sig1(); break;
case 'sig2': sig2(); break;
}

function sig1()
{
include 'sources/sig1.php';
}

function sig2()
{
include 'sources/sig2.php';
}
?>

the "include 'sources/whatever.php';" was where the actual page is :)

TobyCS
05-04-2009, 10:03 PM
I ended up doing this.



<?php if(!isset($_GET['dj'])){
include('stats.php');
echo '<h2>Shows</h2>

<div class="alpha">
<a href="#123">123</a>
<a href="#A">A</a>
<a href="#B">B</a>
<a href="#C">C</a>
<a href="#D">D</a>
<a href="#E">E</a>
<a href="#F">F</a>
<a href="#G">G</a>
<a href="#H">H</a>
<a href="#I">I</a>
<a href="#J">J</a>
<a href="#K">K</a>
<a href="#L">L</a>
<a href="#M">M</a>
<a href="#N">N</a>
<a href="#O">O</a>
<a href="#P">P</a>
<a href="#Q">Q</a>
<a href="#R">R</a>
<a href="#S">S</a>
<a href="#T">T</a>
<a href="#U">U</a>
<a href="#V">V</a>
<a href="#W">W</a>
<a href="#X">X</a>
<a href="#Y">Y</a>
<a href="#Z">Z</a>
</div>';

echo '<div id="shows">
<div id="A">
<p><a href="index.php?page=shows&dj=testdj">Test DJ</a><br />test</p><hr>

</div>'
;} ?>

<?php
if (isset($_GET['dj'])) {
if(file_exists($_GET['dj'].".php")) {
include ($_GET['dj'].".php"); }
else { echo ('<p>The presenter you selected can not be found.</p>'); }
}
?>

CalumK
05-04-2009, 10:12 PM
well i must say im confused... what is all this?

<div class="alpha">
<a href="#123">123</a>
<a href="#A">A</a>
<a href="#B">B</a>
<a href="#C">C</a>
<a href="#D">D</a>
<a href="#E">E</a>
<a href="#F">F</a>
<a href="#G">G</a>
<a href="#H">H</a>
<a href="#I">I</a>
<a href="#J">J</a>
<a href="#K">K</a>
<a href="#L">L</a>
<a href="#M">M</a>
<a href="#N">N</a>
<a href="#O">O</a>
<a href="#P">P</a>
<a href="#Q">Q</a>
<a href="#R">R</a>
<a href="#S">S</a>
<a href="#T">T</a>
<a href="#U">U</a>
<a href="#V">V</a>
<a href="#W">W</a>
<a href="#X">X</a>
<a href="#Y">Y</a>
<a href="#Z">Z</a>
</div>

I think your best bet is to use a Mysql database, and, query it with the dj's name ...
I would explian it all here, but really googeling it will be more help.
This way you could add info to the databse, and it would update easily...

TobyCS
05-04-2009, 10:17 PM
I don't know whether I am allowed to post a link to my testing site, I will post it and check with the rules. If it is against I will remove.

This is what I am trying to do: http://www.tcsdesign.co.uk/radio/index.php?page=shows

CalumK
05-04-2009, 10:31 PM
well, it looks good... Im mystified as to the proble you are having.. it all seems to work fine...
your links copy across...
so all you need to do, is display information relevant to the DJ yes?

EDIT: in fact, your AutoDJ works perfctly...

Is the problem solved?

TobyCS
05-04-2009, 10:34 PM
Yeah it works now after you helped me from the first post. I have probably made it more complicated than it needs to be.

CalumK
05-04-2009, 10:35 PM
oh.. good! glad to help



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum