How to fetch data from database and display it in PHP?

后端 未结 4 1556
不知归路
不知归路 2021-01-17 01:55

How do I get data from a database using php and show it?

The database table has columns, labeled as ID & Number. ID is unique & fix

4条回答
  •  囚心锁ツ
    2021-01-17 02:26

     0)
    {
        //Query the DB
        $resource = mysql_query("SELECT * FROM table WHERE id = " . $id);
        if($resource === false)
        {
            die("Database Error");
        }
    
        if(mysql_num_rows($resource) == 0)
        {
            die("No User Exists");
        }
    
        $user = mysql_fetch_assoc($resource);
    
        echo "Hello User, your number is" . $user['number'];
    }
    

    This is very basic but should see you through.

提交回复
热议问题