looping MySQL query result in PHP
Translations
Englishالعربية
български
català
中文
čeština
dansk
Nederlands
eesti
suomi
français
Deutsch
Ελληνικά
עברית
हिंदी
magyar
Bahasa Indonesia
italiano
日本語
한국어
latviešu
lietuvių
norsk
polski
Português
română
русский
slovenčina
slovenski
español
svenska
ไทย
Türkçe
українська
Tiếng Việt
$b = 1;
$d = mysql_query("select *from 'table_name'");
while($b < 10){
while($e = mysql_fetch_array($d)){
echo $e['name_field'];
}
$b++;
}
I want to loop the output, but I'm stuck. I've tried but still got nothing. something like this :
<?php
$a = 0;
$b = 0;
for($a=0;$a<10;$a++){
for($b=0;$b<10;$b++){
echo $b;
}
}
This question and answers originated from www.stackoverflow.com
Question by repickmukalw (5/14/2011 12:28:43 PM)
Answer |
Seperate * and FROM by a space. Use backticks or no delimiters instead of single quotes for the table name.
If you want to limit your result, add a LIMIT expression to your query:
SELECT * FROM `table_name` LIMIT 10
And then loop through the results:
while($row = mysql_fetch_array($d)){
echo $row['name_field'];
}
Answer by Alp
Find More Answers