Forum Moderators: coopster
[example.com...]
and have it the display the items from the table with with the id that is number 1. How would I do that?
Example
Table
id...name...image....date
1....test...g.jpg....01/01/05
2....teser..e.jpg....12/01/05
and when your go to
[example.com...]
It opens up the db and table so that it displays
test g.jpg 01/01/05
if you go to
[example.com...]
it displays
tester e.jpg 12/01/05
[example.com...]
To reference the id on your item.php page, use the following:
$id = $_GET['id'];
Then your query would be something like:
$query = mysql_query("SELECT * FROM table WHERE id = '$id' LIMIT 1") or die(mysql_error());
Then use one of the fetch methods to display your data, ie: mysql_fetch_row, mysql_fetch_object, mysql_fetch_assoc etc etc
An example using mysql_fetch_object would be:
$row = mysql_fetch_object($query);
echo $row->name . " " . $row->image . " " . $row->date;
Hope that helps.
dc
if (empty($id))
{
header("Location: [yoursite.com");...]
}
The header function must be used before any other data is sent to the browser. If you don`t want to use this, then a few echo commands will do:
if (empty($id))
{
echo "Oops! This page is invalid\n";
echo "Please choose a link:<br><br>\n";
echo "<a href=\"page.php\">Page</a>\n";
exit;
}
exit terminates execution.
Hope that helps.
dc
you can do an
if ($_GET['*']) {
}
for each where star = id, user, or offer. you can also do this
<?
$i = "1";
foreach ($_GET as ${'key' . $i} => ${'val' . $i}) {
$i++;
}
?>
$key1 will equal id and $val1 will equal 1
$key2 will equal user and $val2 will equal 12
$key 3 will equal offer and $val3 will equal 1
if you take out the $i = "1"; and $i++
and do this instead:
<?
foreach ($_GET as $key => $val) {
}
?>
then each one will equal key and val during it's pass so the first pass $key will be id, the second pass $key will be user, the third pass $key will be offer