$item = $_GET['item'];
$id = $_GET['id'];
if(empty($item)){
$query = "SELECT * FROM items WHERE name='$id' LIMIT 1";
}else{
$item = str_replace("-"," ","$item");
$query = "SELECT * FROM items WHERE name='$item' LIMIT 1";
}
$result = mysql_query($query) or die(mysql_error());
$row=mysql_fetch_array($result);
i have changed how the items in my site are found, it used to be done by ?id=x but i wanted it to be made more user friendly so the url can be more readable to the customer. So instead of having just the items id being displayed i now use the title ?item=x . This works fine but many of my links off search engines are on the old id format so i need to detect if the item doesnt contain a string/value then look for an id. Thank You😉