P
P
paulvales2015-09-17 13:21:07
WordPress
paulvales, 2015-09-17 13:21:07

How to set new variables with values ​​from the database?

Hello, cb65dd16033b482b916783128661431b.png
you need to select records from a table by date (datee column)
and using a cycle (I don’t know any other way) create variables and write data to them from the received request .
For example
, if we select for 2015-09-16
then

$prost1 = 23:52:00;
$proend1 = 00:25:00;
$prost2 = 00:00:00;
$proend1 = 00:00:00;
$prost3 = 00:00:00;
$prost4 = 00:00:00;

......
I try with foreach but it outputs 64 records. It's totally confusing.
$query=mysql_query("SELECT * FROM $mes WHERE datee='2015-09-16'");
$arr=mysql_fetch_assoc($query);

$i=0; 
foreach ($arr as $key) {
  ${"num{$i}"} =$key["prost"];
  echo 'N'.$i.' '. ${"num{$i}"}.'<br>';
   $i++;
}

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
nrgian, 2019-04-22
@nrgian

These are mutually exclusive paragraphs:
VDS is such a thing where you set it up yourself, you follow it yourself. Therefore without the administrator it is impossible.
Take better VIP-shared hosting, not VDS type. This is a common shared type, but only your server is inside the VDS, that is, the performance is the same as on the VDS.
https://ruweb.net/hosting/vip

@
@Predaytor, 2019-04-22
_

Machost is a great solution. Support - angels.

P
paulvales, 2015-09-17
@paulvales

Decided like this:

$query="SELECT * FROM $mes WHERE datee='2015-09-16'";
$result=mysql_query($query);
$i=1;
while ($row = mysql_fetch_assoc($result)){
$shablon->setValue('N'.$i,$row["num"]);
$shablon->setValue('PT'.$i,$row["prost"]);
$shablon->setValue('PD'.$i,$row["proend"]);
$shablon->setValue('PS'.$i,$row["prosum"]);
$shablon->setValue('IT'.$i,$row["intst"]);
$shablon->setValue('ID'.$i,$row["intend"]);
...
$i++;}
$shablon->save($anketaFile);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question