Bazı kodlar burada, php ile bir diziye mağaza mysql sorgu sonucu istiyorum, ama benim kod geri dönüş sonucum: 2h
, ne istediğimi değil (doğru sonuç 36,35,34 olmalı, 33,32)mysql sorgusu sonucu php dizisi
<?php
set_time_limit(59);
mysql_select_db("mycoon",$db);
mysql_query("SET NAMES utf8");
$result = mysql_query("SELECT id,link FROM mytable Order By id DESC LIMIT 0,5");
$new_array[] = $row;
while ($row = mysql_fetch_array($result)) {
$new_array[$row['id']] = $row;
$new_array[$row['link']] = $row;
}
mysql_close($db);// close mysql then do other job with set_time_limit(59)
foreach($new_array as $array){
echo $array['id'].'<br />';
echo $array['link'].'<br />';
}
?>
Sonuç:
while($row = mysql_fetch_assoc($result)){
$new_array[] = $row; // Inside while loop
}
Ya da belki bir mağaza kimliği:
36
http://localhost/img/img36.jpg
36
http://localhost/img/img36.jpg
35
http://localhost/img/img35.jpg
35
http://localhost/img/img35.jpg
34
http://localhost/img/img34.jpg
34
http://localhost/img/img34.jpg
33
http://localhost/img/img33.jpg
33
http://localhost/img/img33.jpg
32
http://localhost/img/img32.jpg
32
http://localhost/img/img32.jpg
Kişisel SQL geçersiz görünüyor:
linki ve kimliği almak için 'NEREDE Sipariş By' - "NEREDE" koşulu yok. – hsz
@hsz, sağa. Aslında, orijinal kodum çok uzun, kolay bir soru soracağım, kodumu kısalttım ama '' '' 'un kaldırılmayı unutma. –
[Bir sayı dizini ile ilişkili bir dizi döndürebilir misiniz?] (Http://stackoverflow.com/questions/339371/), [MySQL sorgusunda her sonuç için, diziye (karmaşık)] itin (http://stackoverflow.com/questions/3047896/) ve *** *** *** diğerleri (kaç tane bulabiliriz?). – outis