Jump to content

search for other fields by username


beennn

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 />";  }?>

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

Archived

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

×
×
  • Create New...