PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
One way to see it mapped our is to do a print_r($arr); (either wrap it with <pre><tt><?php print_r($arr); ?></tt></pre> tags or do View Source to see it formatted nicely).
Print_r is a little more neater than var_dump when you know it is only arrays.
I had tried the print_r etc, and looked at the array, but when I tried to access an element nothing happened.
Seems that I was using mysql_fetch_assoc($result) and I couldn't get to an enumerated element, however I could with mysql_fetch_row($result).
I was under the impression that the mysql_fetch_assoc($result) gave both types of access.
Now I see that the favored method of fetching a record is to use the mysqli api.
Thanks for you help
Lonestarjack wrote:I had tried the print_r etc, and looked at the array, but when I tried to access an element nothing happened.
When you say "nothing happened" do you mean that nothing was displayed? Did you check to see if what you were accessing isset()?
Lonestarjack wrote:Seems that I was using mysql_fetch_assoc($result) and I couldn't get to an enumerated element, however I could with mysql_fetch_row($result).
I was under the impression that the mysql_fetch_assoc($result) gave both types of access.
I would recommend having an associative array returned. Then if you insert a column in the table schema your code does not break.
Lonestarjack wrote:Now I see that the favored method of fetching a record is to use the mysqli api.
1, Nothing displayed.
2. I normally use the associative, but in this case I wanted to use the enumerative method.
3. Can always add it on the end.
The page in question has been working well for the past 5 years. It is a large hard coded table that I would rather drive by an array and loops.