For loop in php prints everything twice?
-
i have a table with single value, yet when i write the below code it repeats twice value1 value1 value2 value2 value3 value3 anyone any idea what is wrong... i know i can use extract() function but want to know why it doesnt work for foreach while($row = mysql_fetch_array($results)) { echo "<tr>\n"; foreach($row as $value) { echo "<td>\n"; echo $value; echo "</td>\n"; } echo "</tr>\n"; }
-
Answer:
You have a while AND a for! Rewrite it this way: while ( $row = mysql_fetch_array ($results) ) { echo "<tr> \r\n"; echo $row [ 0 ] ; echo "</td> \r\n"; } (Spaces added)
BenBot at Yahoo! Answers Visit the source
Related Q & A:
- Why is the last input printed twice in the text.txt?Best solution by dreamincode.net
- How to store data in php and get data from php?Best solution by Stack Overflow
- Why do humans often sneeze twice?Best solution by Yahoo! Answers
- What do you do with all the money when you have won the lottery jackpot twice?Best solution by Quora
- What is the difference between a for loop, a do while loop and a do loop?Best solution by wiki.answers.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.