There is a code:

$result = mysql_query("SELECT * FROM inv where username='".$_SESSION['username']."' "); while ($inv= mysql_fetch_array($result)){ echo " i['запись'] = new Array('".$inv['id']."','".$inv['id_img']."','".$inv['kolovo']."',0,'".$inv['title']."',0,'".$inv['about']."',0,6); "; } 

How to make each following entry be one more toist:

 i['1'] i['2'] i['3'] 

...

Closed due to the fact that the essence of the question is not clear to the participants of Pavel Mayorov , Akina , aleksandr barakin , ermak0ff , user194374 3 Feb '17 at 6:10 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • An interesting construct, in echo you create an array and immediately want to display it. First you need to create, and then display. Or output data from the database immediately in a loop, without any array. - DemoS

1 answer 1

 function fetch($res){ while($row=mysql_fetch_assoc($res)) {$data[] = $row;} return $data; } // Db connection $data = fetch(mysql_query("SELECT * FROM inv where username='".$_SESSION['username']."' ")); // Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ это ΠΈ всС Ρ‡Ρ‚ΠΎ Π²Ρ‹ Ρ…ΠΎΡ‚Π΅Π»ΠΈ, Π½ΠΎ Ссли Π½Π΅Ρ‚ ΠΈ Π²Ρ‹ Ρ…ΠΎΡ‚Π΅Π»ΠΈ ΡƒΠ²Π΅Π»ΠΈΡ‡ΠΈΡ‚ΡŒ // ΠΊΠ°ΠΊΠΈΠ΅ Π»ΠΈΠ±ΠΎ значСния массива - // array increment $dataLength = count($data); for($i=0; $i<$dataLength; ++$i) { ++$data[$i]['id']; // Π½Π°ΠΏΡ€ΠΈΠΌΠ΅Ρ€ ΡƒΠ²Π΅Π»ΠΈΡ‡ΠΈΠΌ Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ id } 

PS: learn materiel, with it you are clearly not frets ...

  • Thank you guys =) - oOKomarOo