Tuesday, 15 May 2012

Php variable error in loop -



Php variable error in loop -

its me again....

for ($j=0; $j<mysql_num_fields($ergebnis);$j++) { echo '<table class="center_me table_styled table_inline">'; echo '<tr class="full fill_me">'; echo "\t<td>" . mysql_field_name($ergebnis, $j) ."</td>\n"; echo '</tr>'; while($zeile = mysql_fetch_row($ergebnis)) { echo '<tr class="full">'; echo "<td>".$zeile[$j]."</td>\n"; echo '</tr>'; } echo '</table>'; }

in php script $j counts in loop, in while loop $j 0 , while part got execute 1 time....

(and yes need split tables this.... table 1 = fieldname1 fieldata1 fielddata2 ...... table 2 = fieldname2 fieldata1 fielddata2 ......

old script:

<table border="1"> <tr> <?php $query = "select * kunden;"; $ergebnis = mysql_query($query); ($j=0; $j<mysql_num_fields($ergebnis); $j++) { echo "\t<td>" . mysql_field_name($ergebnis, $j) ."</td>\n"; } ?> </tr> <?php while ($zeile = mysql_fetch_row($ergebnis)) { echo "<tr>"; ($j=0; $j<mysql_num_fields($ergebnis); $j++) { echo "<td>" . $zeile[$j] . "</td>\n"; } echo "</tr>\n\n"; } mysql_free_result($ergebnis); ?> </table>

php loops

No comments:

Post a Comment