Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

Display database contents within HTML

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Spacemail by SpaceshipSpacemail by Spaceship
Watch

Archeyreece

Established Member
Impact
3
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

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
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Try this.

PHP:
<?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
 
0
•••
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:
0
•••
Not a problem.. if you need help with anything else just hit me up
 
0
•••
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

Watched threads: your alert now keeps up with new replies
When you watch a thread, each new reply now updates your alert. Before, you got one alert and then nothing until you read the thread...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back