Jump to content

changing the number of times to run foreach


Jnerocorp

Recommended Posts

Ok I am making a form that the user inputs the following:

 

 

URL (input type=text name=url)

HEIGHT (input type=text maxchars=3 name=height)

WIDTH (input type=text maxchars=3 name=width)

Number (input type=text name=number) of times to display per refresh

 

The form will be using GET and processed on the same page

 

That field "Number" is the field that I want to set for the number of times to run foreach OR it will be the number of times to place "URL" into an arrray

 

so if someone puts 5 it will either display URL 5 times or put "URL" in the same array 5 times please let me know if i am explaining this clear enough or not.

 

-John

 

 

 

Ok Neither of those codes are working i am not getting errors though

 

the url i tested it with is this:

http://jnerocorp.com/for.php?url=http://google.com&?number=2

 

 

this is the Code I am using


<?php
if(isset($_GET['number']) && is_int($_GET['number']))  {

$number = $_GET['number'];
$url = $_GET['url'];

for ($i = 0; $i < $number; $i++) {
    echo "$url <br>";
}

}
?>

 

 

-john

is this the code you are currently using, exactly as seen below:

 

<?php
if(isset($_GET['number']) && is_int($_GET['number']))  {

$number = $_GET['number'];
$url = $_GET['url'];

for ($i = 0; $i < $number; $i++) {
    echo "$url <br>";
}

}
?>

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.