Her birincil anahtar kendi sütununda Atama

0 Cevap php
//Define your database settings.
define('DB_HOST', '');
define('DB_PORT', '');
define('DB_USER', '');
define('DB_PASS', '');
define('DB_NAME', '');

$database = new MySQLi(DB_HOST, DB_USER, DB_PASS, DB_NAME, DB_PORT);

// Escape the id, incase it's a malicious input.
$id = $database->real_escape_string($id);

$sql = 'SELECT Brand.brand, Model.model, Price.price' 
. ' FROM Model' 
. ' INNER JOIN Brand ON Model.brand_id = Brand.brand_id' 
. ' INNER JOIN Price ON Model.model_id = Price.model_id' 
. ' WHERE Price.price BETWEEN 1 AND 5';

$result = $database->query($sql);

// Begin building some HTML output

$html = '<table border="0">
<tr>
<th></th>
</tr>';

while ($row = $result->fetch_assoc())
{
    $html .= '<tr><td>' . $row['brand'] . '</td></tr>';
    $html .= '<tr><td>' . $row['model'] . '</td></tr>';
    $html .= '<tr><td>' . $row['price'] . '</td></tr>';
}

$html .= '</table>';

echo $html;

Example HTML Table output to my webpage right now is one column going all the way down

-----------
|ID 1     |
-----------
|Audi     |
-----------
|A3    |
-----------
|$22,000  |
-----------
|ID 2     |
-----------
|BMW      |
-----------
|3Series  |
-----------
|$24,000  |
-----------
| ID3
---------
|Cadillac
-------
|....... keeps going down to ID10

Ne elde etmek istiyorum her sütun kendi kimliği karşısına gidiyor atayan

--------------------------------------
|ID 1     |ID2      |ID3      | >>>> so on going across to ID10
------------------------------------
|Audi     |BMW      |Cadillac |
----------------------------------
|A3    |3Series  |....     |
---------------------------------
|$22,000  |$24,000  |..       |
--------------------------------

0 Cevap