欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

How to fetch data from mysql table using mysql_fetch_assoc i_MySQL

程序员文章站 2022-05-25 13:37:06
...

php mysql_connect('localhost','root','') or die(mysql_error());

mysql_select_db('new') or die(mysql_error());

$query=mysql_query('select * from table1') or die(mysql_error());

while($res=mysql_fetch_assoc($query))

{

echo'

';

}

echo'

Game_ID Category Title
'.$res['game_ID'].' '.$res['category_Name'].' '.$res['game_Title'].'
';

?>

Now you'll get output like this:

How to fetch data from mysql table using mysql_fetch_assoc i_MySQL

Where,

the result of array should be like this:

Array(

[game_ID] => 1

[category_Name] => Adventures

[game_Title] => Achilles

)

Suppose you'll use

echo'

';


That means you use numeric index instead associative, then you will get undefined offset error like as follows as:

How to fetch data from mysql table using mysql_fetch_assoc i_MySQL

How to fetch data from mysql table using mysql_fetch_assoc i_MySQL

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频


网友评论

文明上网理性发言,请遵守 新闻评论服务协议

我要评论
  • How to fetch data from mysql table using mysql_fetch_assoc i_MySQL
  • 专题推荐

    作者信息
    How to fetch data from mysql table using mysql_fetch_assoc i_MySQL

    认证0级讲师

    推荐视频教程
  • How to fetch data from mysql table using mysql_fetch_assoc i_MySQLjavascript初级视频教程
  • How to fetch data from mysql table using mysql_fetch_assoc i_MySQLjquery 基础视频教程
  • 视频教程分类
    '.$res[0].' '.$res['category_Name'].' '.$res['game_Title'].'