adammc
1
Hi guys,
How can perform the following:
if url conains:
categoryid=117
categoryid=123
categoryid=124
categoryid=125
categoryid=126
echo “clothing logo”;
if url conains:
categoryid=118
echo “play logo”;
if url conains:
categoryid=119
echo “home logo”;
$currentpage = $_SERVER[‘REQUEST_URI’];
…
You could use a series of “if … else” blocks to compare the supplied ID in turn and echo the appropriate reply.
adammc
3
thanks for the reply…
but what function do I use to check if url contains… ?
$categoryid = parse_str(parse_url($_SERVER[‘REQUEST_URI’], PHP_URL_QUERY));
$categoryid = $categoryid[‘categoryid’];
Why not fetch it via the GET array:
if (isset($_GET['categoryid'])) {
$categoryid=$_GET['categoryid'];
}
adammc
6
SpacePhoenix,
how do you do multiple checks at once (to limit coding)
if($categoryid==‘117’) or 118 or 119 {
do something
}
Wow, what was I thinking?! I was stupid. 
adammc
8
OK, I got this far…
Is this coding ok?
if (isset($_GET['categoryid'])) {
$categoryid=$_GET['categoryid'];
if($categoryid=='117') {
echo "clothing logo";
}
elseif($categoryid=='123') {
echo "clothing logo";
}
elseif($categoryid=='124') {
echo "clothing logo";
}
elseif($categoryid=='125') {
echo "clothing logo";
}
elseif($categoryid=='126') {
echo "clothing logo";
}
elseif($categoryid=='118') {
echo "playtime logo";
}
elseif($categoryid=='119') {
echo "home logo";
}
elseif($categoryid=='120') {
echo "baby logo";
}
else {
echo '<div id="logo-pg-2"></div>';
}
adammc
9
damn… my if else structure must not be right… I got a blank page when trying to oad up the page with the code on it 
Can anyone possibly help?
if (isset($_GET['categoryid'])) {
$categoryid=$_GET['categoryid'];
}
if($categoryid=='117') {
echo "clothing logo";
}
elseif($categoryid=='123') {
echo "clothing logo";
}
elseif($categoryid=='124') {
echo "clothing logo";
}
elseif($categoryid=='125') {
echo "clothing logo";
}
elseif($categoryid=='126') {
echo "clothing logo";
}
elseif($categoryid=='118') {
echo "playtime logo";
}
elseif($categoryid=='119') {
echo "home logo";
}
elseif($categoryid=='120') {
echo "baby logo";
}
else {
echo '<div id="logo-pg-2"></div>';
}
You would have had an error due to missing a } after the isset… block. To see the errors you will need to enable error display in php.ini
Or perhaps even an associated array:
$logoTypes = array(
'117' => 'clothing',
'123' => 'clothing',
'124' => 'clothing',
'125' => 'clothing',
'126' => 'clothing',
'118' => 'playtime',
'119' => 'baby',
'120' => 'baby'
);
echo $logoTypes[$categoryId] . ' logo';
adammc
12
i got it using
<?
$categoryid=$_GET['categoryid'];
if($categoryid=='117') {
echo '<div id="logo-clothing"></div>';
}
elseif($categoryid=='123') {
echo '<div id="logo-clothing"></div>';
}
elseif($categoryid=='124') {
echo '<div id="logo-clothing"></div>';
}
elseif($categoryid=='125') {
echo '<div id="logo-clothing"></div>';
}
elseif($categoryid=='126') {
echo '<div id="logo-clothing"></div>';
}
elseif($categoryid=='118') {
echo '<div id="logo-playtime"></div>';
}
elseif($categoryid=='119') {
echo '<div id="logo-home"></div>';
}
elseif($categoryid=='120') {
echo '<div id="logo-baby"></div>';
}
else {
echo '<div id="logo-pg-2"></div>';
}
?>
thank yoou soooo much for your help
Or even, a structure based on the logo types:
$logoTypes = array(
'clothing' => array('117', '123', '124', '125', '126'),
'playtime' => array('118'),
'baby' => array('119', '120')
);
foreach ($logoTypes as $logoType => $ids) {
if (in_array($categoryId, $ids)) {
echo $logoType . ' logo';
}
}