Jump to content

search for other fields by username


beennn
 Share

Recommended Posts

So this will work so long as no 2 ages are the same? what happens then?EDIT: Ahh looks like i didnt read all the way through the tut.found what im looking for; altho before i start to implement it into my site, will this come accross any problems when it comes to having multiple values?

<?php$con = mysql_connect("localhost","peter","abc123");if (!$con)  {  die('Could not connect: ' . mysql_error());  }mysql_select_db("my_db", $con);$result = mysql_query("SELECT * FROM PersonsWHERE FirstName='Peter'");while($row = mysql_fetch_array($result))  {  echo $row['FirstName'] . " " . $row['LastName'];  echo "<br />";  }?>

Edited by beennn
Link to comment
Share on other sites

So this will work so long as no 2 ages are the same? what happens then?EDIT: Ahh looks like i didnt read all the way through the tut.found what im looking for; altho before i start to implement it into my site, will this come accross any problems when it comes to having multiple values?
<?php$con = mysql_connect("localhost","peter","abc123");if (!$con)  {  die('Could not connect: ' . mysql_error());  }mysql_select_db("my_db", $con);$result = mysql_query("SELECT * FROM PersonsWHERE FirstName='Peter'");while($row = mysql_fetch_array($result))  {  echo $row['FirstName'] . " " . $row['LastName'];  echo "<br />";  }?>

There's no problem if the names are unique. If the names aren't unique, then you will have to show a list of results. That's shown right there in the tutorial.A proper database table must always have at least one unique field.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...