-3

Im wondering how do I echo a SINGLE rows fields, for example:

|username|

user1

user2

user3

user4

user5

how would I echo ALL fields in a row onto a php or html page? "I tried" to google it but I couldnt find this, I could only find echoing all ROWS. please help.

Adrian Cid Almaguer
  • 7,815
  • 13
  • 41
  • 63
viewers.gq
  • 21
  • 8
  • When you're getting a row from a database, you're either getting an object returned or an array. All you need to do is access the first element of that array or object and echo that, if you wish to echo out a single row. – Andrei Jun 08 '15 at 09:15
  • i dont understand andrew :( im not a pro and when i google i dont understand, and yeah @sourabh – viewers.gq Jun 08 '15 at 09:19
  • This post might help you, it deals with columns: http://stackoverflow.com/questions/5229501/how-get-all-values-in-a-column-using-php – hlh3406 Jun 08 '15 at 09:25

1 Answers1

0

if you have a mysql database then use:

$SQL = "SELECT <Rowname> FROM <Tablename>";
$query = mysqli_query(<db-connection>,$SQL);
while($row = mysqli_fetch_object($query)){
echo $row-><Rowname>;
}
mcg
  • 1
  • 3