MYSQL - Select specific value from a fetched array

后端 未结 9 1469
青春惊慌失措
青春惊慌失措 2021-01-06 01:45

I have a small problem and since I am very new to all this stuff, I was not successful on googling it, because I dont know the exact definitions for what I am looking for.

9条回答
  •  清歌不尽
    2021-01-06 02:43

    I used the code from the answer and slightly modified it. Thought I would share.

    $result = mysql_query( "SELECT name FROM category;", db_connect() );
    $myrow = array();
    while ($myrow[]  = mysql_fetch_array( $result, MYSQLI_ASSOC )) {}
    $num = mysql_num_rows($result);
    

    Example usage

    echo "You're viewing " . $myrow[$view_cat]['name'] . "from a total of " . $num;
    

提交回复
热议问题