M24KPM
04-28-2006, 01:09 AM
I have not been able to find this so hopefully someone here can help me...how do I make it so that my navigation will be something like this..
Tutorials:http://www.site.com/tutorials.php?id=..
Downloads:http://www.site.com/downloads.php?id=..
---------------
Also I am trying to set up a search feature, how do I make direct the search a specific database?
zactanaz
04-28-2006, 01:31 AM
<?php
function one() {
//Your code here
}
function two() {
//Your code here
}
function three() {
//Your code here
}
switch($op) {
case "one":
one();
break;
case "two":
two();
break;
case "three":
three();
break;
default:
one();
break;
}
?>
Linking Examples:
http://mysite.com/myfile.php?op=one
http://mysite.com/myfile.php?op=two
http://mysite.com/myfile.php?op=three
The default page will be fuction one.
Or u can try this:
<?php
if(!isset($id)){
die("Id not set");
} else {
//Your code goes here.
}
?>
M24KPM
04-28-2006, 02:43 AM
do i need to put that in every document? And what does the "switch" tag do when it makes it past #3?
Nightfire
04-28-2006, 03:35 AM
Best way is to use a database. Will be more efficiant too if you've got loads of files/pages.
On the example above, once you get past 'three' it'll go to the default page, ie: one.
So if you've got hundreds of pages, you'll have hundreds of 'case's in a switch, which wouldn't seem resourceful to me. Best way if you don't have a db is probably to use an array:
http://uk2.php.net/array
Then check if the page is in the array by using
http://uk2.php.net/in_array
/* security checks done, connected to db etc etc */
$sql = "SELECT data FROM table WHERE id='$id'";
$query = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($query) == '1'){
echo 'Page found, echo all info from db entry';
}else{
echo 'Page not found, show error';
}