Jump to content

Archived

This topic is now archived and is closed to further replies.

Nothadoth

taking all out of a variable?

Recommended Posts

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?

Share this post


Link to post
Share on other sites
One way,
[code]
<?php
if(strstr($_GET['catmode'], "All ")){
$catmode = str_replace("All ", "", $_GET['catmode']);
}
else{
$catmode = $_GET['catmode'];
}
?>
[/code]

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.