php基本语言总结

2021-04-21 00:27

阅读:506

标签:span   fetch   关联   基本   失败   mysql   png   name   ima   

1,

mysqli_fetch_row记录集获取

mysqli_fetch_row();//用来将查询结果的一行保存至索引数组;

mysqli_fetch_assoc();//用来将查询结果的一行保存至关联数组;

mysqli_fetch_array();//前2者的结合。

php

$conn=mysqli_connect("localhost","root","111111","mydb") or die("数据库连接失败");

mysqli_query($conn,set names utf8);




$sql="select * from student";

$result=mysqli_query($conn,$sql)or die("数据查询失败");

while($row=mysqli_fetch_row($result))

{

    print_r($row);

}

?>

技术图片

 

 

php

$conn=mysqli_connect("localhost","root","111111","mydb") or die("数据库连接失败");

mysqli_query($conn,set names utf8);




$sql="select * from student";

$result=mysqli_query($conn,$sql)or die("数据查询失败");

while($row=mysqli_fetch_row($result))

{

    echo "$row[0],$row[1],$row[2],$row[3],$row[4],$row[5]"

    echo "
" } ?>

技术图片

 

 

 

php

    $conn=mysqli_connect("localhost","root","111111","mydb") or die("数据库连接失败");

    mysqli_query($conn,set names utf8);

    


    $sql="select * from student";

    $result=mysqli_query($conn,$sql)or die("数据查询失败");

    while($row=mysqli_fetch_row($result))

    {

        $cols=count($row);

        for($i=0;$i)

        {

             echo $row[$i];

             if($i1)echo ",";

        }

        echo "
"; } ?>

技术图片

 

 

 2

mysqli_fetch_assoc记录集获取

技术图片

 

 

 

php

    $conn=mysqli_connect("localhost","root","111111","mydb") or die("数据库连接失败");

    mysqli_query($conn,set names utf8);

    $sql="select * from student";

    $result=mysqli_query($conn,$sql)or die("数据查询失败");

    while($row=mysqli_fetch_assoc($result))

    {

        echo "row[stu_no],$row[stu_name],$row[sex],$row[birthdate],$row[telephone],$row[email]";

        echo "
"; } ?>

技术图片

 

 

php

$conn=mysqli_connect("localhost","root","111111","mydb") or die("数据库连接失败");

mysqli_query($conn,set names utf8);

$sql="select * from student";

$result=mysqli_query($conn,$sql)or die("数据查询失败");

while($row=mysqli_fetch_assoc($result))

{

    foreach($row as $k=>$v)

        {

        echo $v;

        if($k!="email")echo ",";

        }

    echo "
"; } ?>

技术图片

 

 3

mysqli_fetch_array记录集获取

 

技术图片

 

 

while($row=mysqli_fetch_array($result))

{

    $cols=count($row)/2;

    for($i=0;$i)

    {

         echo $row[$i];

         if($i1)echo ",";

    }

    echo "
"; } ?>

技术图片

 

 技术图片

 

 

php

$conn=mysqli_connect("localhost","root","111111","mydb") or die("数据库连接失败");

mysqli_query($conn,set names utf8);

$sql="select * from student";

$result=mysqli_query($conn,$sql)or die("数据查询失败");

echo "";

echo "";

while($row=mysqli_fetch_array($result))

    {

    echo "";

        foreach($row as $k=>$v)

        {

            if(!is_numeric($k)){

            echo "";

            

            }

        }

    echo "";

  


    }

echo "
学号 姓名 性别 出生日期 电话号码 邮箱
$v
"; ?>

技术图片

 

php基本语言总结

标签:span   fetch   关联   基本   失败   mysql   png   name   ima   

原文地址:https://www.cnblogs.com/520520520zl/p/13282843.html


评论


亲,登录后才可以留言!