Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 26th, 2005, 2:06 PM   #1
theguy0000
Programmer
 
Join Date: Jul 2005
Posts: 73
Rep Power: 4 theguy0000 is on a distinguished road
php - print data from SQL

how can i use php to print data from an SQL?
theguy0000 is offline   Reply With Quote
Old Jul 26th, 2005, 2:11 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
I presume you mean from a SQL database. When you query the database from PHP (properly) results are returned, commonly in an array. Output that.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 26th, 2005, 2:13 PM   #3
theguy0000
Programmer
 
Join Date: Jul 2005
Posts: 73
Rep Power: 4 theguy0000 is on a distinguished road
how do i query the database from php? would i just use
SELECT * FROM table
theguy0000 is offline   Reply With Quote
Old Jul 26th, 2005, 2:14 PM   #4
skuinders
Hobbyist Programmer
 
skuinders's Avatar
 
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4 skuinders is on a distinguished road
Expanding on what DaWei said, the result is returned in a rowset (or 2D array). You cannot simply print this data structure, so you probably want to use a foreach loop to go through each row and print the relevant column values.
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand."
- B. Russell

http://web.bryant.edu/~srk2
skuinders is offline   Reply With Quote
Old Jul 26th, 2005, 2:16 PM   #5
skuinders
Hobbyist Programmer
 
skuinders's Avatar
 
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4 skuinders is on a distinguished road
Quote:
Originally Posted by theguy0000
how do i query the database from php?
http://www.php.net/mysql
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand."
- B. Russell

http://web.bryant.edu/~srk2
skuinders is offline   Reply With Quote
Old Jul 26th, 2005, 2:28 PM   #6
theguy0000
Programmer
 
Join Date: Jul 2005
Posts: 73
Rep Power: 4 theguy0000 is on a distinguished road
thanks, both of you.
theguy0000 is offline   Reply With Quote
Old Jul 26th, 2005, 2:33 PM   #7
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
The PHP manual is absolutely one of the best examples of its kind I've ever seen. Whether it's on your local medium or on-line, bookmark it. As a PHP novice I typically search for the name of a C/C++ utility that I'm familiar with. Quite often, PHP has an adaptation, frequently with the warts removed. The benefit of the navigation bar on the left is that once you find what you're looking for, you can see a lot of additional alternatives that are sometimes even better than what you were anticipating.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 26th, 2005, 8:16 PM   #8
theguy0000
Programmer
 
Join Date: Jul 2005
Posts: 73
Rep Power: 4 theguy0000 is on a distinguished road
uhh...ok let me make exactly what it is i need a bit clearer. i want to display it like a foum does.

for example: specify the post id, which would be one of the columns in the table "myforum_posts". it would display the value of the "post_content" column in the "(postID)" row.

i have tried to exmine phpbb's "viewtopic.php" but I don't understand all thaat.
theguy0000 is offline   Reply With Quote
Old Jul 26th, 2005, 8:34 PM   #9
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Well, you display it by sticking the part of the results you want into HTML markup.... Is that what you're asking? You build the presentation by generating the markup with PHP or by sandwiching PHP values/results in at the appropriate place in static markup. Then the server sends the page (or finishes sending the page).
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 26th, 2005, 8:52 PM   #10
theguy0000
Programmer
 
Join Date: Jul 2005
Posts: 73
Rep Power: 4 theguy0000 is on a distinguished road
ok thanks.
theguy0000 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:28 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC