2016-11-01 9 views
-1

in allen Reihen kommen Überschrift müssen in der ersten Reihekommen Überschrift in allen Reihen

mit Hilfe nötig, wo ich falsch werde

danke

Sie den Code unten ist

<?php 
$connection = mysql_connect('localhost', 'aria2', 'osvOSUxlY6wYLZzC'); //The  Blank string is the password 
mysql_select_db('torres'); 
$query = "SELECT * FROM reports"; //You don't need a ; like you do in SQL 
$result = mysql_query($query) or die(mysql_error());; 
    echo "<table>"; // start a table tag in the HTML 
    while($row = mysql_fetch_array($result)){ //Creates a loop to loop through results 
    echo "<table><tr><th>CSQ_Name</th> 
    <th>CSQ_ID</th>....... 
$row.............. 
    //$row['index'] the index here is a field name 
      } 
      echo "</table>"; //Close the table in HTML 
    mysql_close(); //Make sure to close out the database connection 
+0

Ich verstehe nicht für Ihre Frage mehr beschreiben. –

+3

Echo Ihre Tabelle Header vor der Schleife, nicht in der Schleife - Simple! –

+2

Niemals Benutzernamen und Passwort in Ihrem Code hier eingeben. – RST

Antwort

1

Sie müssen nur den Header-Teil aus der Schleife verschieben:

echo '<table><tr><th>CSQ_Name</th><th>CSQ_ID</th></tr>'; // start a table tag in the HTML 
while ($row = mysql_fetch_array($result)) { //Creates a loop to loop 
    echo '<tr>'; 
    // output data here 
    echo '<td>...</td><td>...</td>'; 
    echo '</tr>'; 
} 
echo "</table>"; //Close the table in HTML