NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Display database contents within HTML

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
6 members in live chat ~  


Reply
 
LinkBack Thread Tools
Old 07-16-2011, 12:12 AM THREAD STARTER               #1 (permalink)
NamePros Regular
 
Archeyreece's Avatar
Join Date: Jan 2009
Location: Canada
Posts: 237
Archeyreece is on a distinguished road
 



Display database contents within HTML


Alright so I've been trying to get PHP to display some data from a table in my database. I want it to look like this: http://i53.tinypic.com/2hzjo5i.png

but all im getting is this: http://i56.tinypic.com/1znoc45.jpg
????: NamePros.com http://www.namepros.com/programming/723335-display-database-contents-within-html.html

and this is the PHP portion of my code
Code:
<?php

$queryTitle = mysql_query("SELECT title FROM posts");
$queryDate = mysql_query("SELECT date FROM posts");
$queryBody = mysql_query("SELECT body FROM posts");

while($rowTitle = mysql_fetch_array($queryTitle)){
  echo "<h2>" . $rowTitle['title'] . "</h2>";
  echo "<br />";
  }
while($rowDate = mysql_fetch_array($queryDate)){
	echo "<h4>" . $rowDate['date'] . "<h4>";
	echo "<br />";
}

?>
Thanks,
Archey
Archeyreece is offline   Reply With Quote
Old 07-16-2011, 05:06 AM   #2 (permalink)
Ray
CEO
 
Ray's Avatar
Join Date: Jun 2005
Location: Tennessee
Posts: 1,894
Ray has much to be proud ofRay has much to be proud ofRay has much to be proud ofRay has much to be proud ofRay has much to be proud ofRay has much to be proud ofRay has much to be proud ofRay has much to be proud ofRay has much to be proud of
 



Try this.

PHP Code:

????: NamePros.com http://www.namepros.com/showthread.php?t=723335
<?php

$query 
mysql_query("SELECT * FROM posts");

while(
$row mysql_fetch_array($query)){
  echo 
"<h2>" $row['title'] . "</h2>";
  echo 
"<br />";
  echo 
"<h4>" $row['date'] . "<h4>";
  echo 
"<br />";
  }

?>
PHP processes code from top to bottom unless a class or function is called thus creating a block effect for your code. Also the way you were requesting to pull info from the database is by calling specific information, or in other words ordered data. Using the * denote allows you to pull any information at request without the need for extra coding. if you need more help with this pm me
Ray is online now   Reply With Quote
Old 07-18-2011, 05:52 AM THREAD STARTER               #3 (permalink)
NamePros Regular
 
Archeyreece's Avatar
Join Date: Jan 2009
Location: Canada
Posts: 237
Archeyreece is on a distinguished road
 



nice, that worked, but they are displaying Ascending from 1-## i want them to descend from ##-0. Anyone know what i have to do?

EDIT: nvm, i found it, just had to add
Code:
ORDER BY id DESC
to my query
Last edited by Archeyreece; 07-18-2011 at 06:02 AM.
Archeyreece is offline   Reply With Quote
Old 07-18-2011, 10:36 AM   #4 (permalink)
Ray
CEO
 
Ray's Avatar
Join Date: Jun 2005
Location: Tennessee
Posts: 1,894
Ray has much to be proud ofRay has much to be proud ofRay has much to be proud ofRay has much to be proud ofRay has much to be proud ofRay has much to be proud ofRay has much to be proud ofRay has much to be proud ofRay has much to be proud of
 



Not a problem.. if you need help with anything else just hit me up
Ray is online now   Reply With Quote
Reply


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
50,000 human reviewed links database - built to order CrackFeed.Com Content For Sale 1 06-24-2011 04:09 PM
World Hotels Database with 208,065 Hotels - Very Comprehensive Fields & Images immediate Content For Sale 0 06-04-2011 04:24 AM
wordpress readymade database for Sell yengkok Content For Sale 0 05-22-2011 12:44 AM

 
All times are GMT -7. The time now is 02:48 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger