#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    1
    Rep Power
    0

    Unhappy 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>&nbsp;</p></td>
    </tr>
    </table>';
    }
    } else{
    $dynamicList = "We have no products in our store yet";
    }
    /*$qObj->displayTable();*/
    pg_close();
    ?>
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,301
    Rep Power
    7170
    Clarify what you mean by not working.

    I'm not too familiar with pg, but I'm not sure you're supposed to have double quotes around your field and table names.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo