PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 29th, 2003, 10:36 AM
hperez hperez is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 30 hperez User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 1 m 55 sec
Reputation Power: 10
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.

Reply With Quote
  #2  
Old July 29th, 2003, 10:40 AM
christo's Avatar
christo christo is offline
Introspective
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Nov 2001
Location: London, UK
Posts: 3,317 christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 5 h 42 m 28 sec
Reputation Power: 109
Send a message via ICQ to christo Send a message via Yahoo to christo
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

Reply With Quote
  #3  
Old July 29th, 2003, 10:44 AM
christo's Avatar
christo christo is offline
Introspective
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Nov 2001
Location: London, UK
Posts: 3,317 christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 5 h 42 m 28 sec
Reputation Power: 109
Send a message via ICQ to christo Send a message via Yahoo to christo
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

Reply With Quote
  #4  
Old July 29th, 2003, 10:44 AM
hperez hperez is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 30 hperez User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 1 m 55 sec
Reputation Power: 10
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.

Reply With Quote
  #5  
Old July 29th, 2003, 10:48 AM
hperez hperez is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 30 hperez User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 1 m 55 sec
Reputation Power: 10
Smile

THANK YOU!!!! It works. When I plugged in $result->fetchRow() it started to work. THANK YOU!!!!!

Reply With Quote
  #6  
Old July 29th, 2003, 10:52 AM
christo's Avatar
christo christo is offline
Introspective
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Nov 2001
Location: London, UK
Posts: 3,317 christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 5 h 42 m 28 sec
Reputation Power: 109
Send a message via ICQ to christo Send a message via Yahoo to christo
np dude

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > Displaying records

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap