Simple way to read single record from MySQL

后端 未结 20 1275
一整个雨季
一整个雨季 2020-11-30 23:46

What\'s the best way with PHP to read a single record from a MySQL database? E.g.:

SELECT id FROM games

I was trying to find an answer in t

20条回答
  •  离开以前
    2020-12-01 00:24

    Easy way to Fetch Single Record from MySQL Database by using PHP List

    The SQL Query is SELECT user_name from user_table WHERE user_id = 6

    The PHP Code for the above Query is

    $sql_select = "";
    $sql_select .= "SELECT ";
    $sql_select .= "  user_name ";
    $sql_select .= "FROM user_table ";
    $sql_select .= "WHERE user_id = 6" ;
    
    $rs_id = mysql_query($sql_select, $link) or die(mysql_error());
    list($userName) = mysql_fetch_row($rs_id);
    

    Note: The List Concept should be applicable for Single Row Fetching not for Multiple Rows

提交回复
热议问题