
February 7th, 2013, 07:53 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 1
Time spent in forums: 29 m 11 sec
Reputation Power: 0
|
|
Trying to pull info/pics from a PG database using PHP
I am making a car rental website for school, and im trying to pull the cars info, pics, and videos from the schools database and be displayed on the web pages...
this is the code i currently have..what i am trying to do is load the vehicles page with car info using a dynamic table. However many items in the car table from the query should be displayed in a table...Its not working! althouh the query produces a result set..maybe someone can help me out....
<?php
//Connect to DB
require("MyConnection.php");
require("MyCode.php");
$obj = new MyConnection();
$obj->setConn();
$obj->displayValues();
$qObj = new MyCode();
$qObj->setConn( $obj->getConn());
//Run a Select Query to get items
$dynamicList ="";
$q = "SELECT
\"RatePerDay\",
\"MakeModel\",
\"TransmissionType\",
\"Horsepower\",
\"Engine\",
\"Description\",
\"CarImage\"
FROM
carrentaltest.\"CAR\"";
$qObj->setQuery($q);
$productCount = pg_num_rows($q);
if ($productCount >0){
while($row = pg_fetch_array($q)){
$rate = $row["RatePerDay"];
$vehicle_name = $row["MakeModel"];
$transmission = $row["TransmissionType"];
$horsepower = $row["Horsepower"];
$engine = $row["Engine"];
$description = $row["Description"];
$image = $row["CarImage"];
$dynamicList .= '<table width="618" border="2">
<tr>
<td width="274" valign="top"><a href="#"><img style="border:#0C0 1px solid" src="images/' . $image . '.jpg" width="272" height="202" alt="' . $vehicle_name . '" /></a></td>
<td width="326" valign="top">
<p>' . $vehicle_name . '</p>
<p>$' . $rate . '</p>
<p>' . $horsepower . '</p>
<p>' . $engine . '</p>
<p>' . $transmission . '</p>
<p>' . $description . '</p>
<p> </p></td>
</tr>
</table>';
}
} else{
$dynamicList = "We have no products in our store yet";
}
/*$qObj->displayTable();*/
pg_close();
?>
|