I checked this page, but do not see the answer to my question!
So do you know that if it is possible, or not, to fetch data from a MySQL query multiple time? I see NO reason why this would not be yes, but again my attempts to fetch data from a query beyond the 1st fetch are not working.
while ($result_get_kws = mysql_fetch_array($query_get_kws)) {
//get this data and do X1 with it
}
But when I go to use it again, that is:
while ($result_get_kws = mysql_fetch_array($query_get_kws)) {
//get this data and do X2 with it.
}
Then the data is not available!!!
So would I have to generate the Sql query again? I dont see why this would be the case since that would be very inefficient.
What is preventing you to store the entire result of the query within an array and then use it as many times as you want in your script?
You can loop trough it as many times as you want, without repeating the query.
But I wanted to know whether in MySQL/PHP the content of a query remain available to be fetched again or they are available for fetching only once? If only once, then this sounds really stupid, really inefficient. So I am just wondering about this question and not that I dont have other solutions for getting the data that was retrieved by the Query command.
If there is a solid solution provided for that particular reason then you cannot say that it is stupid. The query result does not loose its result but when looping, the internal result pointer goes at the last and you need to set it to the first (0) before you use it. What is the problem using mysql_data_seek() function?
Aha, now I see what is going on.
So the data of query is not lost, but once one loops through the query then the counter remains on the last position and needs to be set back to the first(0) position. Got it. So does mysql_data_seek() do this?
I mean if my query is:
$query_get_kws = mysql_query($sql_get_kws) or die(mysql_error());
// and then this
while ($result_get_kws = mysql_fetch_array($query_get_kws)) {
//do x here
}
Then how do I reset the counter for $query_get_kws back to first(0)?