<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("names") or die(mysql_error());
$green = "rose";
$data = mysql_query("SELECT * FROM freinds2 WHERE name = '"$green"');
or die(mysql_error());
Print "<table border cellpadding=3>";
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
Print "<th>Name:</th> <td>".$info['name'] . "</td> ";
Print "<th>Pet:</th> <td>".$info['pet'] . " </td></tr>";
Print "<th>Color:</th> <td>".$info['fav_color'] . "</td> ";
Print "<th>Food:</th> <td>".$info['fav_food'] . " </td></tr>";
}
Print "</table>";
?>
The above code works fine until I try and replace the name= in the SELECT statement with the variable I created above $green = 'rose'.It wont take the variable the way I put it in the SELECT statement.Is there a special way of placing variables in a select statement.? Many thanks jim