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:
  #1  
Old July 17th, 2003, 02:28 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
Individule data

I am having a little difficulty subtracting data from an SQL database. What I would like to do is for every row in that database use this code:
php Code:
Original - php Code
  1.  
  2. <table border="1" width="20%" bordercolor="000088" bgcolor="DDDDFF"  cellpadding="5">
  3.     <tr>
  4.         <td colspan="2">
  5.             <center>
  6.             <font face="georgia" size="4" color="000088">
  7.             NAME
  8.             </font>
  9.             </center>
  10.         </td>
  11.     </tr>
  12.     <tr>
  13.         <td width="50%">
  14.             <font face="georgia" size="3" color="000088">
  15.             DESCRIPTION
  16.             </font>
  17.         </td>
  18.         <td width="50%">
  19.             <font face="georgia" size="3" color="000088">
  20.             <img src="FILENAME">
  21.             </font>
  22.         </td>
  23.     </tr>
  24.     <tr>
  25.         <td colspan="2">
  26.             <font face="georgia" size="3" color="000088">
  27.             DATE
  28.             </center>
  29.         </td>
  30.     </tr>
  31. </table>

and instead of NAME, DESCRIPTION, FILENAME and DATE I would like to use the data from the database. My database is called 'pictures' and the table I would like to extract from is called 'info'. In the 'info' table the columns are called 'name', 'filename', 'description' and 'date'. All of them are text exept 'date' which is datetime.
Thankyou.

Reply With Quote
  #2  
Old July 17th, 2003, 03:29 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: Individule data

What Programming language are you using? What DB are you using MSSQL (Microsoft) or MySQL. Do you have an prior programming experience?

Let us know.

Reply With Quote
  #3  
Old July 18th, 2003, 07:11 AM
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
RE: Individule data

I am using a MySQL database and I do not have much programming experience although I am trying to learn.

Reply With Quote
  #4  
Old July 20th, 2003, 07:41 AM
tkarkkainen's Avatar
tkarkkainen tkarkkainen is offline
Moderator
Click here for more information
 
Join Date: Apr 2007
Location: Finland
Posts: 2,326 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: 15677 Folding Title: Novice Folder
Time spent in forums: 6 Days 9 h 32 m 40 sec
Reputation Power: 4
RE: Individule data

Ok, here's a simple script that reads the info from your db.

php Code:
Original - php Code
  1.  
  2. <?php
  3. $conn = mysql_connect("localhost", "username", "password"); //connect to database server
  4. mysql_select_db("pictures"); //we use "pictures" database
  5. $sql="SELECT * FROM info"; //select every column from table called info
  6. $result=mysql_query($sql, $conn) //do the database query
  7. ?>
  8. <table border="1" width="20%" bordercolor="000088" bgcolor="DDDDFF"  cellpadding="5">
  9. <?php
  10. while($row=mysql_fetch_array($result)) // Here we get all the results from the query
  11. {
  12. ?>
  13.     <tr>
  14.         <td colspan="2">
  15.             <center>
  16.             <font face="georgia" size="4" color="000088">
  17.             <?php echo $row['name']; //we print out the contents of the 'name' column ?>
  18.             </font>
  19.             </center>
  20.         </td>
  21.     </tr>
  22.     <tr>
  23.         <td width="50%">
  24.             <font face="georgia" size="3" color="000088">
  25.             <?php echo $row['description']; ?>
  26.             </font>
  27.         </td>
  28.         <td width="50%">
  29.             <font face="georgia" size="3" color="000088">
  30.             <img src="<?php echo $row['filename']; ?>">
  31.             </font>
  32.         </td>
  33.     </tr>
  34.     <tr>
  35.         <td colspan="2">
  36.             <font face="georgia" size="3" color="000088">
  37.             <?php echo $row['date']; ?>
  38.             </center>
  39.         </td>
  40.     </tr>
  41. <?php
  42. }
  43. ?>
  44. </table>


I suggest you buy a book about PHP and databases. Generally people on this forum don't like people who just ask for ready scripts. I tried to comment the script above as much as possible so it'd be easier for you to learn from it.

Reply With Quote
  #5  
Old July 21st, 2003, 07:41 AM
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
RE: Individule data

Thankyou for you reply. I am sure I will learn from it. Can you reccomend any PHP/database books?
Thankyou again.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Individule 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 1 hosted by Hostway