Well, I know there is a funciton mysql_fetch_array() and we can use it like this:
while ($row = mysql_fetch_array($result)) {
 echo $row['name'] . "<br />"; 
}
But is开发者_运维技巧 there any other way? For example, if there is only one element that can be returned, and not an array.
Thanks)
see mysql_result():
Retrieves the contents of one cell from a MySQL result set.
If there's only going to be one row then you can just say:
$row = mysql_fetch_array($result);
Or you can use mysql_fetch_row if you want.
But I'd second Erik's comment to go with PDO. Here's a good tutorial making heavy use of PDO.
You could use mysql_result
$result = mysql_query($query) or die(mysql_error());
$scalar = mysql_result($result, 0);
For example, if there is only one element that can be returned, and not an array.
Nope.
Only array or a useless object you can get.  
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论