No announcement yet.

Converting Function to return MYSQL_ASSOC information

  • Filter
  • Time
  • Show
Clear All
new posts

  • Converting Function to return MYSQL_ASSOC information


    I really need some help with the following, i have a function which returns an 2 dimentional array (i believe you call it that way?) from a MySQL query..

    However this function returns an numerical array (?) with value's like Array[0][0], Array[0][1] etc... however i need this function to return an ASSOCIATIVE array, like Array[0]["id"] Array[0]["name"] etc

    (the first dimention of the array can still be numerical, thats no problem)
    Could anyone help please?
    Last edited by Helza; Tue 18 Jun '02, 11:00am.

  • #2
    Use mysql_fetch_array() instead of mysql_fetch_row(), and set the second argument of the former to MYSQL_ASSOC if you only want it to return an associative array only. (otherwise it will also store the values in numeric indexes)
    Chen Avinadav
    Better to remain silent and be thought a fool than to speak out and remove all doubt.

    גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב


    • #3
      got it

      Thanks for the help..
      Last edited by Helza; Tue 18 Jun '02, 11:39pm.


      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.