MySQL Column Count in PHP
Ive been tasked to create a website for an electrical engineers company and need a bit of help and advice on a problem.
The sites going to be database driven and so far runs on three pages.
The problem I have at the moment is I need to called the database columns on a page, but they are different for each product.
My idea was to use the mysqli_fetch($r, MYSQLI_NUM) and then loop through number 0 to the last one called back.
This is where I get stumpted could anyone tell me a good way or loop to do this?
Is there a command that can count the number of columns called so I can use this in the loop?
Thanks in advance.
If using MySQLi, the result's $field_count property is all you need to get the number of fields.
However, if your intent is just to loop through all of them, there's really no need since you can just use a foreach loop:
while($row = $result->fetch_row())
foreach($row as $value)
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)