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

    Join Date
    Jul 2003
    Posts
    30
    Rep Power
    12

    Question Displaying records


    I am beggining to using PostgreSQL and I have a question about how to display my database's records. This is the code I have:

    PHP Code:
    <html>
    <head>
    <title>Service Appointments Database</title>
    </head>
    <body>
    <?php 
        
    include('../../adodb165/adodb.inc.php');
        
    $conn = &ADONewConnection('postgres7');
        
    $conn->PConnect('localhost','webadmin','password','dbname');
        
    $result $conn->Execute("SELECT * FROM serviceappts ORDER BY time DESC");
    ?>

    <table border="1" cellpadding="3">
      <tr> 
        <td bgcolor="#CCCCCC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>ID</strong></font></td>
        <td bgcolor="#CCCCCC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Customer 
          Name</strong></font></td>
        <td bgcolor="#CCCCCC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Vehicle 
          Information</strong></font></td>
        <td bgcolor="#CCCCCC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Service 
          Advisor</strong></font></td>
        <td bgcolor="#CCCCCC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Date 
          Submited</strong></font></td>
        <td bgcolor="#CCCCCC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>View Record</strong></font></td>
      </tr>
      <?php 
        
    while($row pg_fetch_row($result))
        {
    ?>
      <tr> 
        <td><?php echo $row["id"]; ?></td>
        <td><font size=2 face=Verdana, Arial, Helvetica, sans-serif><?php echo $row["first_name"]; ?><?php echo " " ?><?php echo $row["last_name"]; ?></font></td>
        <td><font size=2 face=Verdana, Arial, Helvetica, sans-serif><?php echo $row["year"]; ?><?php echo " " ?><?php echo $row["make"]; ?><?php echo " " ?><?php echo $row["model"]; ?> 
          </font> </td>
        <td><font size=2 face=Verdana, Arial, Helvetica, sans-serif> <?php echo $row["advisor"]; ?></font></td>
        <td> 
          <?
            $datefromdb 
    $row['time'];
            
    $year substr($datefromdb,0,4);
            
    $mon  substr($datefromdb,4,2);
            
    $day  substr($datefromdb,6,2);
            
    $hour substr($datefromdb,8,2);
            
    $min  substr($datefromdb,10,2);
            
    $sec  substr($datefromdb,12,2);
            
    $orgdate date("l F d, Y h:i A",mktime($hour,$min,$sec,$mon,$day,$year));
        
    ?>
          <? echo $orgdate?> </TD>
        <td align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><a href="view_service_appointment.php?id=<?php echo $row['id']; ?>">View</a></font></TD>
      </tr>
      <?php
       
    }
    ?>
    </table>
    </BODY>
    </HTML>
    I am having a problem with the while($row = pg_fetch_row($result)). When I run this code I get the following message:

    Warning: Supplied argument is not a valid PostgreSQL result resource in /home/hperez/public_html/mysite/pages/test/appointments.php on line 27

    Can someone please help me with my code? Any help is appreciated. Thank you.
  2. #2
  3. Introspective
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Nov 2001
    Location
    London, UK
    Posts
    3,317
    Rep Power
    110
    This is most likey because your query is failing. Can you try just echoing the query onto the screen, then cut and paste it into a pg dialogue to see if it runs?


    christo
    This is me: http://chris.uk.com
  4. #3
  5. Introspective
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Nov 2001
    Location
    London, UK
    Posts
    3,317
    Rep Power
    110
    Incidentally, I'm surprised to see something like this, when you are using the ADODB abstraction layer:

    Code:
        while($row = pg_fetch_row($result))
    
        {
    surely that restricts you to fetching rows from pgsql result objects. is't there something you can use which is equivalemtn to PEAR::DB's $result->fetchRow() ?

    just a thought

    christo
    This is me: http://chris.uk.com
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    30
    Rep Power
    12
    I am able to echo the contents of my database onto the screen but I want to display them in a fancier way than just line by line.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    30
    Rep Power
    12

    Smile


    THANK YOU!!!! It works. When I plugged in $result->fetchRow() it started to work. THANK YOU!!!!!
  10. #6
  11. Introspective
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Nov 2001
    Location
    London, UK
    Posts
    3,317
    Rep Power
    110
    np dude
    This is me: http://chris.uk.com

IMN logo majestic logo threadwatch logo seochat tools logo