Forum Moderators: coopster
[edited by: eelixduppy at 12:20 pm (utc) on Mar 29, 2012]
[edit reason] linked url [/edit]
$output=$fname=$lname=$null;
if (isset($_GET['id']) and is_numeric($_GET['id']) and ($_GET['id'] > 0)) {
// You can use *, but specific field names are often more efficient
// One of the rare occasions raw input is OK because we've already verified it's a number
$query = "select `name`,`lastname` from `test` where id=".$_GET['id'];
$result = mysql_query($query) or die("Cannot execute $query");
if ($row = mysql_fetch_array($result)) {
// You may want these individually - see below
$fname = $row['name'];
$lname = $row['lastname'];
$output = "<p>$fname $lname</p>";
}
else {
$output = '<p>No results were found with that query.</p>';
}
}
else { $output = '<p>Invalid input supplied.</p>'; }