Tuesday, 15 February 2011

php - Function inside a loop -



php - Function inside a loop -

i have loop table row , table data. want add together class name on every table info of course of study not same class name.

but problem output of function placing outside table. check quotes or something, still placing outside. can explain me why?

function alphacount(){ ($i=65; $i<=90; $i++) { echo char($i); } for($i=1;$i<=10;$i++) { echo '<td class="char-'.$i.'-'.$this->alphacount.'"> </td>'; }

to honest, don't much of code according problem described, guess problem following.

you have function generates identifier, echoes instead of returning it, this:

function getid() { // echo $id; }

and when generating entry, having next code:

echo "<tr class='" . getid() . "'>...</tr>";

like getid() method echoes identifier before <tr> tag rendered. can resolve either changing echo statement in getid homecoming statement, or can rewrite entry generator in next way:

echo "<tr class='" getid(); echo "'>...</tr>";

i hope had problem with.

php html loops

No comments:

Post a Comment