Jump to content

Archived

This topic is now archived and is closed to further replies.

killerbud99

View as html

Recommended Posts

Hello, I am asking a question refering to this on the main page [url=http://www.phpfreaks.com/tutorials/142/0.php]http://www.phpfreaks.com/tutorials/142/0.php[/url]

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
[code]      // echo out the results to the screen
  while ($list = mysql_fetch_array($result)) {
      echo "{$list['image_url']} <br>";
  } // end while[/code]

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

Thanks in advance  :)

Share this post


Link to post
Share on other sites
You get back an array of hashes... you can do whatever you want with them.

Share this post


Link to post
Share on other sites
[quote author=killerbud99 link=topic=111551.msg452101#msg452101 date=1160918214]
Hello, I am asking a question refering to this on the main page [url=http://www.phpfreaks.com/tutorials/142/0.php]http://www.phpfreaks.com/tutorials/142/0.php[/url]

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
[code]      // echo out the results to the screen
  while ($list = mysql_fetch_array($result)) {
      echo "{$list['image_url']} <br>";
  } // end while[/code]

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

Thanks in advance  :)
[/quote]
Currently the query you use only returns one field. If you wnat all fields returned then use this as the query:
[code]$sql = "select * from testTable"; [/code]
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 [url=http://php.net/mysql-fetch-array]mysql_fetch_array[/url] to help understand whats going on.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.