killerbud99 Posted October 15, 2006 Share Posted October 15, 2006 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 Link to comment https://forums.phpfreaks.com/topic/23999-view-as-html/ Share on other sites More sharing options...
fenway Posted October 15, 2006 Share Posted October 15, 2006 You get back an array of hashes... you can do whatever you want with them. Quote Link to comment https://forums.phpfreaks.com/topic/23999-view-as-html/#findComment-109065 Share on other sites More sharing options...
wildteen88 Posted October 15, 2006 Share Posted October 15, 2006 [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. Quote Link to comment https://forums.phpfreaks.com/topic/23999-view-as-html/#findComment-109082 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.