4
Contributors
6
Replies
8
Views
4 Years
Discussion Span
Last Post by simplypixie
0

No with out that one! Because, I have Id,Ref,Profile,Article,Event ... I can not make the get function for all. I was thinking, something handy with the regex function

0

Thank you for trying to help me guys, but I have this problem wich wasted four hours of my time now, and I can't get it fixed.

    function seo($seo_type){
    if(isset($_GET['a_id']) && !empty($_GET['a_id'])) {

    $number = $_GET['a_id'];
    $query = "SELECT $seo_type FROM d_articles WHERE a_id = '$number'";
    $result = mysql_query($query);

    while($row=mysql_fetch_array($result))
    { echo "$row[$seo_type] - ";    }

    } 
    }

What the above function does is, get id of url ex. site.com/article.php?a_id=77
Now, the function calling is like this, <?php echo seo('page_title'); ?>

Now, when you call the function, it searches page_title FROM d_articles wheere
a_id = 77

Now, it does query and gets results from sql and echos it. Which is good.
But, what if the url does not end with articles.php?a_id=77
What if I have another url that is referece.php?id=22 or user.php?id=44

So, the question boils down to

how can you check what kind of id exists and perform seperte functions as per the function that exits

1

Hi,

So you are trying to get either a_id or id from the URL, depending on which one exists?

if(isset($_GET['a_id']) && !empty($_GET['a_id'])){
    $number = $_GET['a_id'];
} elseif (isset($_GET['id']) && !empty($_GET['id'])){
    $number = $_GET['id'];
}

You can add as many variations as you need.

1

If you really want to get the whole string after the ? you can use something like:

$id = strstr($_SERVER['PATH_INFO'], '?');
$id = str_replace('?','',$id);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.