Suppose I have a request
$array = array(); $sql = mysql_query("SELECT * FROM table"); while($row=mysql_fetch_array($sql)){ $data = $row['data']; } $array = $data;
Now, how can I get each value of $ data from while in array () ie $ array
$array = array(); $sql = mysql_query("SELECT * FROM table"); while ($row = mysql_fetch_array($sql)) { $array[] = $row['data']; }
adding each line of $ to the $ data arrayfor reference: http://php.net/types.array
Note that there is no such thing as a “while () array”. There are only arrays.
$data . $data[], $data , $array [], , , $data .
$data[]
"" , :
$array = array(); $sql = mysql_query("SELECT * FROM table"); while($row=mysql_fetch_array($sql)){ $array[] = $row['data']; }
:
$array[] = $row['data'];
further u can use
$array['data']
and u can also use mysql_fetch_assoc($sql)insteadmysql_fetch_array($sql)
mysql_fetch_assoc($sql)
mysql_fetch_array($sql)
Source: https://habr.com/ru/post/1763347/More articles:conversion from 'std :: string' to the non-scalar type requested - c ++How to display HTML image image - javascriptHow can I use an alias inside a subquery? - sqlCheck if user with ID or X is - wordpressHow to stop will_paginate from getting each record from the database - ruby-on-rails-3PHP time () function returns random time shift by hour - phpusing java program - javaUsing panels in chrome extensions - google-chromeКак определить координаты гиперссылки в WPF - c#Does ASP.NET always require BeginRequest and EndRequest in the same thread? - .netAll Articles