Jump to content

Select records based on value


markspec87

Recommended Posts

[code]$sql = "SELECT * FROM members WHERE username="spec";
$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $sql);
$row = mysql_fetch_array($result);
echo $row['age']. " and ". $echo['location']; // or whatever
[/code]

The above assumes a single match to the query.
is there is more than one

$query = "SELECT * FROM members WHERE username = 'spec'";
$result = mysql_query($query);
if($result){
while($row = mysql_fetch_assoc($result)){
echo "Age: ".$row["age"]."<br />\n";
}

}else{
echo "There has been an error<br />\n"
.mysql_error();
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.