<?php
require('header.php');
?>
<link href="style.css" rel="stylesheet" type="text/css">
<center>
<h2>Friends</h2>
</center>
<?php
require('db_fns.php');
if(isset($_GET['friend']))
{
// Connect to the database server and select database
$db = connectdb();
// Run query to get all inforation
$result = @mysql_query("SELECT id, name, age, friendship, picture FROM friends where name = '$friend'");
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
// Display info in a table
while ( $row = mysql_fetch_array($result) ) {
$id = $row["id"];
$name = $row["name"];
$age = $row["age"];
$friendship = $row["friendship"];
$picture = $row["picture"];
echo
(
"<center>$friendship </A>"
);
};
}
else
{
// Connect to the database server and select database
$db = connectdb();
// Run query to get all inforation
$result = @mysql_query("SELECT id, name, age, friendship, picture FROM friends Order By name");
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
// Display info in a table
while ( $row = mysql_fetch_array($result) ) {
$id = $row["id"];
$name = $row["name"];
$age = $row["age"];
$friendship = $row["friendship"];
$picture = $row["picture"];
echo
(
"<center> <a href='friends.php?friend=$name'>$name - $age</A>"
);
};
}
?>
<?php
require('footer.php');
?>
Ok i have the second part of the if statement pass the variable to itself by reloading the page and the variable is then declared using $_GET but it doesnt work.
Can anyone see a problem ?
/Matt