Jump to content


Photo

View as html


  • Please log in to reply
2 replies to this topic

#1 killerbud99

killerbud99
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 15 October 2006 - 01:16 PM

Hello, I am asking a question refering to this on the main page http://www.phpfreaks...rials/142/0.php

I want to view the output of a sql as html or php as so it can be viewed as such not as a list
      // echo out the results to the screen
   while ($list = mysql_fetch_array($result)) {
      echo "{$list['image_url']} <br>";
   } // end while

Also I would like to pull more info not just the ['image_url'] can this be done?

Thanks in advance  :)

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 15 October 2006 - 03:52 PM

You get back an array of hashes... you can do whatever you want with them.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 15 October 2006 - 04:56 PM

Hello, I am asking a question refering to this on the main page http://www.phpfreaks...rials/142/0.php

I want to view the output of a sql as html or php as so it can be viewed as such not as a list

      // echo out the results to the screen
   while ($list = mysql_fetch_array($result)) {
      echo "{$list['image_url']} <br>";
   } // end while

Also I would like to pull more info not just the ['image_url'] can this be done?

Thanks in advance  :)

Currently the query you use only returns one field. If you wnat all fields returned then use this as the query:
$sql = "select * from testTable";
The astricks (*) means all so now your query selects everything in the table called testTable.

Now in the while loop. The variable $list holds an array of each field for each row returned from the query you just ran. If you do not understand arrays then Id recommend you to learn up on arrays over at http://www.php.net/array also read up on the mysql_fetch_array to help understand whats going on.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users