I need to get simular data from a data base on many pages on my site I descided to make a function so I wont need to right the same code over and over I know the function works i just dont know how to get the data out function getAllItems($what,$where,$ordered){ $query = "SELECT * FROM `items` where `$what`= '$where' ORDER BY '$ordered'"; $result = mysql_query($query); $i=0; while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $id[$i]=$row[id]; $cat[$i]=$row[category]; $pName[$i]=$row[prodname]; $smallD[$i]=$row[smalldescript]; $longD[$i]=$row[longdescript]; $pImage[$i]=$row[image]; $price[$i]=$row[price]; $i++; } $gAI=$i; } -------------------------------------------------- This is how i am retreiving the data -------------------------------------------------- getAllItems("category","Hookah Flavors","prodname"); <? for ($i=0;$i<=$gAI;$i++){ ?> <li><a href="flavors.php?id=<?=$id[$i]?>" target="hookahflavors"><li><?=$pName[$i]?></a></li> <?}?> -------------------------------------------------- The data being retrieved is product info How do i save the arrays from the function so they can be used afterwords I want to use this funtion to create dynamic index pages for all the categories --------------------------------------------------