وظيفة mysql_fetch_array() في PHP
تعريف ووظيفة
يستخرج mysql_fetch_array() صفًا واحدًا من مجموعة النتائج كجداول مرتبطة أو جداول عددية أو ككليهما
يعيد جدولاً مكونًا من الصفوف التي تم استخراجها من مجموعة النتائج، وإذا لم يكن هناك المزيد من الصفوف، يعيد false.
النحو
mysql_fetch_array(data,array_type)
معامل | وصف |
---|---|
data | اختياري. تحديد الإشارة إلى البيانات. هذه الإشارة هي نتيجة mysql_query() |
array_type |
اختياري. تحديد نوع النتيجة المطلوبة. القيم الممكنة:
|
Tips and Comments
Note:mysql_fetch_array() is mysql_fetch_row() the extended version. In addition to storing data in the array in numeric index mode, data can also be stored as associative index, using field names as key names.
Tip:An important point must be pointed out, using mysql_fetch_array() is not obviously better than using mysql_fetch_row() Slow and also clearly provides more values.
Note:The field names returned by this function are case-sensitive.
Example
<?php $con = mysql_connect("localhost", "hello", "321"); if (!$con) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db("test_db",$con); $sql = "SELECT * from Person WHERE Lastname='Adams'"; $result = mysql_query($sql,$con); print_r(mysql_fetch_array($result)); mysql_close($con); ?>
Output similar to:
Array ( [0] => Adams [LastName] => Adams [1] => John [FirstName] => John [2] => London [City] => London )