Forum Moderators: coopster
Heat = <?php echo $home['heat'];?><br>
Displays the array in my database that needs to be unserialized.
Heat = <?php echo unserialize($home['heat']);?><br>
Displays the word "Array"
How do I write the code line so that I can see the unserialized array written as a list on my page?
Thank you.
Thank you so much! Now I get:
Heat = Array ( [0] => Electric [1] => Gas [2] => Solar )
I would like this to look like an indented list (I added dots ..... because this forum took out my added spaces when I tried to post. I just want each item in the list to be indented):
.....Electric
.....Gas
.....Solar
I thought it should be easy to pull an array from a database and unserialize it into a list. Maybe it isn't so easy.
There has to be a way to change Array ( [0] => Electric [1] => Gas [2] => Solar ) to just a list of the array values. I've been Googling for a couple of hours now, and can't seem to find what I am looking for.
implode is a new one on me!
One last question...If there is nothing in the database for a particular array, I get:
"Warning: implode() [function.implode]: Bad arguments..."
What would I need to change in your code to make sure this message does not come up?
Before I made the if/else change, my site was down twice due to exceeded cpu usage. Called my host and was told there was a query that took over 40 seconds. Could this have been caused by a php page being called that hadn't been created yet in my database (ex: mysite/page.php?id=39 when there are only 35 records in the database)? What I am thinking is that when I was testing the page I am creating and called a non-existant page (getting the Warning: implode() [function.implode]: Bad arguments.), it may have taken excessive time to query the database (though I can't remember anything taking over 40 seconds to process). Could this possibly be the reason for the cpu overage?