php - Use of two dimensional array -


i facing problem while wanting fetch rows following table namely date.

id      name       username    app      sdate    edate    ===    =======     ========    ===      =====    ======    1      tanvir      tanvir      1       2012      2012         2      ranvir      ranvir      1       2011      2013        3      john        john        2       2011      2012       4      rakib       rakib       1       2011      2012   

i use following mysql query:

$date = mysql_query("select * `date`"); $date_row = mysql_fetch_array($date); 

but returning single row.

how can put of rows 2 dimensional array?

well of course it's returning 1 row, that's mysql_fetch_array does:

mysql_fetch_array — fetch a result row associative array, numeric array, or both

now, build array of rows, have iterate on them:

$all_rows = array(); while($row = mysql_fetch_assoc($date)) $all_rows[] = $row; 

notice how use mysql_fetch_assoc here. should never use mysql_fetch_array unless need both numeric , associative indices.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -