Jump to content


Photo

taking all out of a variable?


  • Please log in to reply
2 replies to this topic

#1 Nothadoth

Nothadoth
  • Members
  • PipPipPip
  • Advanced Member
  • 119 posts

Posted 16 August 2006 - 10:09 PM

I have a question. At the moment I'm using a script to select and show all items from the database WHERE subcategoryname='$catmode'.

Now on some of the ones catmode will be something simple like "Hardware". That's easy.

However, i've had it so some of them are "All Hardware" (for example).

Is there anyway to put before the WHERE query a code that will say for instance something like.

if ($_GET['catmode'] contains "All ") {

$catmode = $_GET['catmode'] without "All ";

} else {

$catmode = $_GET['catmode'];

}



Obviously that wouldn't work. But is there some way I can do something like that? Or not?

#2 Prismatic

Prismatic
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego

Posted 16 August 2006 - 10:29 PM

One way,
<?php
if(strstr($_GET['catmode'], "All ")){
	$catmode = str_replace("All ", "", $_GET['catmode']);
}
else{
	$catmode = $_GET['catmode'];
}
?>


#3 Nothadoth

Nothadoth
  • Members
  • PipPipPip
  • Advanced Member
  • 119 posts

Posted 16 August 2006 - 10:52 PM

It didn't work.

However it seams looking at my site that I don't actually need this code when I thought I did.

Thank you none the less :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users