PHP Abfrage aus SQL Datenbank <td> wird nicht horizontal angezeigt

Seiyaru2208

Captain
Registriert
Apr. 2008
Beiträge
3.112
Hallo Jungs,

da bin ich wieder diesmal habe ich absolut keilen Ahnung was ich falsch gemacht habe... hier erstmal mein Code...

PHP:
<?php
  
	$sql = "SELECT prcontent.*, preis.abrechnungszeitraum AS price_name
	FROM prcontent
	JOIN preis
	ON prcontent.price_id = preis.id";
	$res = mysql_query($sql);
       
?>

<table>
	
	<tr>
		
		<th>Abrechnungsmodus</th>
		<th>1/4 Stunde</th>
		<th>1/2 Stunde</th>
		<th>3/4 Stunde</th>
		<th>1 Stunde</th>
	</tr>
<?php	
	while($row = mysql_fetch_assoc($res))
	{
?>	
	
	<tr>
		<td></td>
		<td><?php echo $row['betrag']; ?></td>
		
	</tr>
<?php
}
?>	
</table>

Das Problem ist das die $row`s nach unten ausgegeben werden und nicht wie gewünscht horizontal.

Sprich unter 1/4 Stunde soll betrag x stehen usw.
 
Zuletzt bearbeitet:
ist ja auch logisch!
dein <tr> steht mit in der schleife - guck dir doch mal den produzierten html quelltext an!
 
entschuldige bitte.... ich bin wie gesagt neu in PHP ich schau grade drauf wie ein Kuh ins Uhrwerk... kannst du mir zeigen wie es richtig aussehen muss... auch nur Beispielhaft.... :/
 
Mach in Zeile 26 das <tr> weg und pflanze es zwischen </tr> und <?php ein.

Das </tr> aus Zeile 30 kommt dann über das </table>.
 
PHP:
<?php
    
   
	$sql = "SELECT prcontent.*, preis.abrechnungszeitraum AS price_name
	FROM prcontent
	JOIN preis
	ON prcontent.price_id = preis.id";
	$res = mysql_query($sql);
       
?>

<table>
	
	<tr>
		
		<th>Abrechnungsmodus</th>
		<th>1/4 Stunde</th>
		<th>1/2 Stunde</th>
		<th>3/4 Stunde</th>
		<th>1 Stunde</th>
	</tr>
<?php	
	while($row = mysql_fetch_assoc($res))
	{
?>	
	
	
		<td></td>
		<td><?php echo $row['betrag']; ?></td>
		
<tr>	
<?php
}
?>
</tr>
</table>

Ich habe es jetzt so geändert.....

nichts hat sich geändert
 
Das produziert ungültiges HTML. Du öffnest mehrere "TR" in der Schleife und schließst nur ein "TR".
 
@Fireball... and @all
Vielen Dank das wars

PHP:
<?php
    
   
	$sql = "SELECT prcontent.*, preis.abrechnungszeitraum AS price_name
	FROM prcontent
	JOIN preis
	ON prcontent.price_id = preis.id";
	$res = mysql_query($sql);
       
?>

<table>
	
	<tr>
		
		<th>Abrechnungsmodus</th>
		<th>1/4 Stunde</th>
		<th>1/2 Stunde</th>
		<th>3/4 Stunde</th>
		<th>1 Stunde</th>
	</tr>
	
	<td></td>	
<?php	
	while($row = mysql_fetch_assoc($res))
	{
?>	
	
	
		
		<td><?php echo $row['betrag']; ?></td>
		



<?php
}
?>
</tr>
</tr>
</tr>
</tr>

</table>

Jetzt wird alles richtig ausgegeben! :D Vielen Dank für die schnelle Hilfe =)
 
Aber nur weil Browser heutzutage sehr tolerant sind bei der Tabellendarstellung :D
Bitte füge in Zeile 22 ein <tr> ein und entferne Zeile 39,49 und 41.
 
Autsch! Mache es so, Mausi ;)
PHP:
<?php
$res = mysql_query('SELECT prcontent.*, preis.abrechnungszeitraum AS price_name FROM prcontent JOIN preis ON prcontent.price_id = preis.id');
?>
<table>
	<tr>
		<th>Abrechnungsmodus</th>
		<th>1/4 Stunde</th>
		<th>1/2 Stunde</th>
		<th>3/4 Stunde</th>
		<th>1 Stunde</th>
	</tr>
	<tr>
		<td></td>
<?php
while($row = mysql_fetch_assoc($res))
{
	echo '<td>'.$row['betrag'].'</td>';
}
?>
	</tr>
</table>
 
Zurück
Oben