Jump to content

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.