码迷,mamicode.com
首页 > 数据库 > 详细

php mysql_connect()

时间:2017-05-29 20:35:36      阅读:249      评论:0      收藏:0      [点我收藏+]

标签:job   close   color   roo   connect   query   local   border   array   

<?php
$q=$_GET["q"];

$con = @mysql_connect(‘localhost‘, ‘root‘, ‘root‘);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}

mysql_select_db("job", $con);

$sql="SELECT * FROM world WHERE id = ‘".$q."‘";

$result = mysql_query($sql);

echo "<table border=‘1‘>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
<th>Hometown</th>
<th>Job</th>
</tr>";

while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row[‘FirstName‘] . "</td>";
echo "<td>" . $row[‘LastName‘] . "</td>";
echo "<td>" . $row[‘Age‘] . "</td>";
echo "<td>" . $row[‘Hometown‘] . "</td>";
echo "<td>" . $row[‘Job‘] . "</td>";
echo "</tr>";
}
echo "</table>";

mysql_close($con);

php mysql_connect()

标签:job   close   color   roo   connect   query   local   border   array   

原文地址:http://www.cnblogs.com/mudebao/p/6918857.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!