Jump to content

Loops making me crazy again


zartzar

Recommended Posts

This basically creates a table with a for loop, with 10 rows, and within each of that row is a for loop generated drop down menu that goes from 0 - 50000, however i cant get the drop down menu to work. I dont even get any errors, its just blank. Im tearing my hair out!!!!!!

 

 

print "<table border='1'>";

 

for($c=1; $c<=10; $c++)

 

{

print "<tr> <td>$c</td> <td><input type='text' name='$c' size='20'></td> <td>R

 

<select name='valincome'>

for($cc=0; $cc<=50000; $cc=$cc+100)

{

<option value='$cc'>$cc</option>

}

</select> </td> </tr>";

 

}

 

print "</table>";

Link to comment
https://forums.phpfreaks.com/topic/147825-loops-making-me-crazy-again/
Share on other sites

<?php
print "<table border='1'>";

for($c=1; $c<=10; $c++){

print "<tr> <td>$c</td> <td><input type='text' name='$c' size='20'></td> <td>";
print "<select name='valincome'>";
	for($cc=0; $cc<=50000; $cc=$cc+100){
		print "<option value='$cc'>$cc</option>";
	}
print "</select> </td> </tr>";

}
print "</table>";
?>

Going a little loopy are we?

 

print "<table border='1'>";

for($c=1; $c<=10; $c++) {
    print "<tr> <td>$c</td> <td><input type='text' name='$c' size='20'></td> <td>
        <select name='valincome'>";

    for($cc=0; $cc<=50000; $cc=$cc+100) {
        print "<option value='$cc'>$cc</option>";
   }

    print "</select> </td> </tr>";
}

print "</table>";

 

You should really learn the Basic Syntax of php, as it shows you are really lacking on that knowledge.

 

EDIT:

Beaten to it :(

<?php
print "<table border='1'>";

for($c=1; $c<=10; $c++){

print "<tr> <td>$c</td> <td><input type='text' name='$c' size='20'></td> <td>";
print "<select name='valincome'>";
	for($cc=0; $cc<=50000; $cc=$cc+100){
		print "<option value='$cc'>$cc</option>";
	}
print "</select> </td> </tr>";

}
print "</table>";
?>

 

Sams the man! So your saying i shouldnt put for loops in print statements?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.