Skip to content

Instantly share code, notes, and snippets.

@johnbocook
Last active December 28, 2015 23:49
Show Gist options
  • Save johnbocook/7581939 to your computer and use it in GitHub Desktop.
Save johnbocook/7581939 to your computer and use it in GitHub Desktop.
The PHP code below, will return the columns firstname, lastname from the Friends table.
<?php
//
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
$result = mysql_query("SELECT friendId,firstName,lastName,nickName FROM friends");
while($row = mysql_fetch_array($result))
{
echo $row['FirstName'] . " " . $row['LastName'];
}
mysql_close($con);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment