$con = mysql_connect(HOST_NAME,USER_NAME,PASSWORD);$sql = "SELECT * FROM users WHERE userid='$userId'";
$res = mysql_query($sql,$con);
$row = mysql_fetch_array($res);
if (is_array($row)){
$userName = $row["username"];
}
mysql_free_result($res);
echo $userName;
$res = mysql_query($sql,$con);
$row = mysql_fetch_array($res);
if (is_array($row)){
$userName = $row["username"];
}
mysql_free_result($res);
echo $userName;
$mylink=mysql_connect("localhost","root","1234");
$sql="SELECT id,name from 表名";
$result_output=mysql_query($sql,$mylink);
if(mysql_num_rows($result_output)>0){
?>
<table width="75%" border="1">
<?php
while($array_yh=mysql_fetch_array($result_output)){
?>
<tr>
<td><?php echo $array_yh['id'];?></td>
<td><?php echo $array_yh['name'];?></td>
</tr>
<?php
}
?>
</table>
<?php
}
?>
$result = mysql_query($sql,$con);//送入数据库查询
for ($i=0; $i<count($array); $i++){//开始循环
$array = mysql_fetch_array($result);//读出数据
echo "$array[A_TITLE]";//显示
}//循环结束
$query = mysql_query($str);
$count = myswl_num_rows($query);
if($count > 0){
while($title_array=mysql_fetch_array){
echo $title_array[A_TITLE];
}
}else{
echo "没有找到任何信息";
}
$mylink=mysql_connect("localhost","root","1234");
$sql="SELECT id,name from 表名";
$result_output=mysql_query($sql,$mylink);
if(mysql_num_rows($result_output)>0){
?>
<table width="75%" border="1">
<?php
while($array_yh=mysql_fetch_array($result_output)){
?>
<tr>
<td><?php echo $array_yh['id'];?></td>
<td><?php echo $array_yh['name'];?></td>
</tr>
<?php
}
?>
</table>
<?php
}
?>
//连接到本地MYSQL数据库
$myconn=mysql_connect("localhost","root","");
//选择数据库,$myconn为活动连接
mysql_select_db("database_name",$myconn);
//用SQL从table_name表中查询
$strSql="select count(*) as count from table_name";
//用mysql_query从表中读出数据
$result=mysql_query($strSql,$myconn);while($row=mysql_fetch_array($result))
{
?>
<tr>
<td align="center"><? echo $row["A_TITLE"]?></td>
</tr>
}
//关闭对数据库的连接
mysql_close($myconn);
?>//接上页
$rs = mysql_query($query,$connectionHandle) or die "error info ";
while($row = mysql_fetch_array($rs))
{
.......$row["字段"]
}