Posted 27 June 2006 - 11:05 AM
hopefully this is an easy answer
i have the following variable
$trainerqry6=mysql_query("SELECT DISTINCT trainers.trainer_id as trainerid, trainers.trainer AS trainer
it works fine - but i want to use the same query several times in different places on the page. how do i make the variable accessible more than once
Thank you and apologies for the stupid question
Posted 27 June 2006 - 11:16 AM
<?php $trainerqry6=mysql_query("SELECT DISTINCT trainers.trainer_id as trainerid, trainers.trainer AS trainer FROM trainers"); ... ... ... ?>
Posted 27 June 2006 - 11:23 AM
it is currently defined at the top of the page in the first block of php code
it works fine when called once but the second time it returns nothing
Posted 27 June 2006 - 11:28 AM
so, it's resultset.
If you like to use it inside a function, you'll need to global it inside that function.
Resultset is special. When you fetch result, the internal pointer of result set point to the next row. So, after a while, eventually, fetch will return null to indicate the end of result.
If you need to re-use the results, you have to mysql_data_seek.
This function move the internal pointer to the location you wanted.
mysql_data_seek($trainerqry6, 0); will reset the resultset
Posted 27 June 2006 - 11:32 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users