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!
function mysql_fetch_all($result) {
$i = 0;
for ($i=0; $i<mysql_num_rows($result); $i++) {
$return[$i] = mysql_fetch_array($result);
}
return $return;
}
I have the above function which after calling to it once won't let me call to it again.
Any way to modify it so i can call it at least twice or possible infinite??
I get this when i call it a second time and print_r the result
umm.... not to be rude but that is a bit irrelevant, as the function works but i need it to call it more than once with arguments which are not the same......
OR are you suggesting that i use the mysql_data_seek() in the function ???.....
Da P3s7 wrote:umm.... not to be rude but that is a bit irrelevant, as the function works but i need it to call it more than once with arguments which are not the same......
OR are you suggesting that i use the mysql_data_seek() in the function ???.....
...
One of the most common mistakes that people make with this function, when using it multiple times in one script, is that they forget to use the mysql_data_seek() function to reset the internal data pointer.
...
Sorry for bringing this up again...
I tried to use mysql_data_seek() to no avail....
The thing is... I don't parse the same query result, i parse a different result.
Although this does give me an idea:
What if i close the mysql connection and then reopen it?
Would that work?
After extensive tries i havent figured out a way of using just one query.
mysql_data_seek() just doesnt seem to be working for me... for some reason...
Both by fathers briliant logic and a friend of mine's programming capapbilities (he works for the company that made the first video-game( pong)) couldn't sort out the mess.
Closing and reopening the connection doesn't work...
However, this friend did suggest a middle file. I'll explain:
He said "make the 2 queries in 2 different files and use the $_POST[] to get the info u need".
Would that work?
What i don't get is why does mysql_num_rows work while the function doesn't work...(@ jenk: your's doesn't work either )
(I use the mysql_num_rows for pagination.) The mysql_num_rows returns the number of rows from the whole table and incredibly works...
This gives you guys any ideas?
@ astions:
Well i need to do 2 different queries:
One is for the indexing system that manually increases the index. (OMG this post just gave me a huge idea)
And the second is to print out the data in the table.