Monday, June 2, 2008

my php to connect database

$N=$_GET["name"];
$con = mysql_connect("localhost", "10514154", "lia154");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$linkdb=mysql_select_db("mim10514154",$con);
if (!$linkdb)
{die ("Could not connect to the Database!".mysql_error());
}
$result=mysql_query("SELECT * FROM `soccer players` where Name ='".$N."'");
if (!$result)
{die ("result false".mysql_error());
}
echo"


";
while($row=mysql_fetch_array($result))
{echo"";echo"";
echo"";echo"";echo"";echo"";echo"";echo"";echo"";echo"";echo"";echo"";echo"";echo"";echo"";echo"";echo"";echo"";echo"";echo"";echo"";echo"";echo"";echo"";echo"";echo"";}
echo"
NameFullnameDate of BirthPositionNumberClubPeriodAppearancesGoalClub2Period2Appearance2Goal2Club3Period3Appearances3Goal3Club4Period4Appearances4Goal4National TeamAppearances in National TeamGoal in National Team
".$row['Name']."". $row['Full Name']."".$row['Date of Birth']."".$row['Position']."".$row['Number']."".$row['Club']."".$row['Period']."".$row['Appearances']."".$row['Goal']."".$row['Club2']."".$row['Period2']."".$row['Appearances2']."".$row['Goal2']."".$row['Club3']."".$row['Period3']."".$row['Appearances3']."".$row['Goal3']."".$row['Club4']."".$row['Period4']."".$row['Appearances4']."".$row['Goal4']."".$row['National team']."".$row['Appearances in National team']."".$row['Goal in National Team']."
";
mysql_close($con);

?>

No comments: