Sure here is an example
Say, I need to pass to a script the recordID of anyting, and something about what I want to do with it.
For example I want to build a list of hyper links that allow me
to edit or delete a record from the db.
I could do this:
$query="select rID, articleName from articles";
$result=mysql_query($query);
for($i=0;$i<mysql_num_rows($query);$i++){
$record=@mysql_fetch_object($result);
echo "
$record->articleName: <a href="myscript.php?id=$record->rID&op=edit">click me to edit</a>
<a href="mysript.ph?id=$record->rID&op=delete">click me to delete</a>";
}
For each record in the db that would output:
Some Article name: edit delete
Some other article name: edit delete
Where edit and delete are links that allow you to do that function on the record
Now for the script myscript.php, the article id and operation woudl be variables in the php defined array $_GET.
Such a script may look like this:
// check to see if the vars a empty
if(empty($_GET[id]) || empty($_GET[op])){
// error, no values passed
echo "are you messing the URL, bad you...";
exit;
}
// check to see if id is not a number
if(!is_int($_GET[id])){
// an invalid article id has been passed
echo "I know you are trying to guess the numbering system!";
exit;
}
switch($_GET[op]){
case "":
echo "Why did you remove the function from the url...? bad you";
break;
case "edit":
// call functon to edit
break;
case "delete":
// call function to delete
break;
}
I know that may be a lot more code than what you wanted to see, but I figured a practicle example would be useful.