Good day.

There is a cycle

do { echo "<option value='$myrow19[id]'>$myrow19[estnet]</option>"; } while($myrow19 = mysql_fetch_array($result19)); 

How can the whole cycle be put into a variable so that this loop can be inserted with the help of this variable at any place in the code?

  • You can simply call the function later - atnartur
  • one
    throw out courses popova! - johniek_comp

3 answers 3

Maybe I mean, in advance to prepare this cloud option'ov and then re-insert it somewhere, somehow?

 $options = ''; do { $options .= sprintf( '<option value="%s">%s</option>', $myrow19[id], $myrow19[estnet] ); } while( $myrow19 = mysql_fetch_array( $result19)); 

And then somewhere in the code:

 echo $options; 
  • Vooooooh this came up thanks - alexsis20102

In variable? This is something new)) You can write this loop into a function and call it in the right place:

 function myCycle($result19) { do { echo "<option value='$myrow19[id]'>$myrow19[estnet]</option>"; } while($myrow19 = mysql_fetch_array($result19)); } // И вызов функции myCycle($result19); 

The function will need to pass the parameter $ result19

  • Why does one line disappear when outputting - alexsis20102

Try to put the loop in a function, and then put the function in a variable:

 function cikl(){ Здесь цикл }