![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Jul 2005
Posts: 73
Rep Power: 4
![]() |
php - print data from SQL
how can i use php to print data from an SQL?
|
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Jul 2005
Posts: 73
Rep Power: 4
![]() |
how do i query the database from php? would i just use
SELECT * FROM table |
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4
![]() |
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 |
|
|
|
|
|
#5 | |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4
![]() |
Quote:
__________________
"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 |
|
|
|
|
|
|
#6 |
|
Programmer
Join Date: Jul 2005
Posts: 73
Rep Power: 4
![]() |
thanks, both of you.
|
|
|
|
|
|
#7 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#8 |
|
Programmer
Join Date: Jul 2005
Posts: 73
Rep Power: 4
![]() |
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. |
|
|
|
|
|
#9 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#10 |
|
Programmer
Join Date: Jul 2005
Posts: 73
Rep Power: 4
![]() |
ok thanks.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|