Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase 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 Codewalkers Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old July 15th, 2003, 04:41 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
Displaying data

Hi,
I have created a database called 'pictures' and in it a table called 'info'. I have submitted some data into the table. I now come to the php,, this is what I have written:

php Code:
Original - php Code
  1.  
  2. <?php
  3.  
  4. /* connect to db */
  5. @mysql_connect or die('Error connecting to MySQL.');
  6. @mysql_select_db ('pictures') or die('Error connecting to database.');
  7.  
  8.  
  9. /* Retrieve the data */
  10. $query = "SELECT * FROM info";
  11. $result = mysql_query ($query);
  12.  
  13. /* Display the data */
  14. echo $result;
  15. ?>


However I get this message 'Resource id #2'. Please could you explain what I am doing wrong.
Thanks

Reply With Quote
  #2  
Old July 15th, 2003, 04:48 PM
tkarkkainen's Avatar
tkarkkainen tkarkkainen is online now
Moderator
Click here for more information
 
Join Date: Apr 2007
Location: Finland
Posts: 2,320 tkarkkainen User rank is Lance Corporal (50 - 100 Reputation Level)tkarkkainen User rank is Lance Corporal (50 - 100 Reputation Level)tkarkkainen User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 10700 Folding Title: Novice Folder
Time spent in forums: 6 Days 8 h 46 m 35 sec
Reputation Power: 4
RE: Displaying data

php Code:
Original - php Code
  1.  
  2. /* Display the data */
  3. echo $result;


Change this to:

php Code:
Original - php Code
  1.  
  2. exho "<table>";
  3. foreach(mysql_fetch_array($result) as $key => $value) {
  4. echo "<tr><td>$key</td><td>$value</td></tr>";
  5. }
  6. exho "</table>";

Reply With Quote
  #3  
Old July 15th, 2003, 06:14 PM
sliver's Avatar
sliver sliver is offline
Moderator
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: WI, USA
Posts: 888 sliver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 17 m 29 sec
Reputation Power: 2
Send a message via AIM to sliver Send a message via XFire to sliver
RE: Displaying data

Quote:
Change this to:


php:
exho "<table>";
foreach(mysql_fetch_array($result) as $key => $value) {
echo "<tr><td>$key</td><td>$value</td></tr>";
}
exho "</table>";
?>


2 errors in that code, it should be:
php Code:
Original - php Code
  1.  
  2. echo "<table>";
  3. foreach(mysql_fetch_array($result) as $key => $value) {
  4. echo "<tr><td>$key</td><td>$value</td></tr>";
  5. }
  6. echo "</table>";
  7. ?>

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Displaying data


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway