在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
<?php //连接参数 $host="localhost"; $user="root"; $pwd="111111"; $db="test"; $linkID =mysql_connect($host,$user,$pwd); //创建一个mysql连接 if(!$linkID){ echo "<font color='red'>unable to connect!</font>"; } mysql_select_db($db)or die("unable to select database"); //选择一个数据库 $SQL_SELECT_SYMBOLS="select * from symbols"; $result=mysql_query($SQL_SELECT_SYMBOLS)or die("error in query :$query. ".mysql_errno()); //执行SQL语句 if(mysql_num_rows($result)>0){ echo '<table cellpadding="10" border="1">'; echo '<tr><th>id</th><th>country</th><th>animal</th><th>cname</th></tr>'; while($obj=mysql_fetch_object($result)){ echo "<tr>"; echo "<td>".$obj->id."</td>"; echo "<td>".$obj->country."</td>"; echo "<td>".$obj->animal."</td>"; echo "<td>".$obj->cname."</td>"; echo "</tr>"; } echo "</table>"; } else{ echo "记录未找到!"; } mysql_free_result($result); //释放记录集所占用的内存 mysql_close($linkID); //关闭数据库连接 ?> |
2022-07-18
2022-08-17
2022-11-06
2022-07-08
2022-08-17
请发表评论