Jump to content

Access query data before while loop?


son
 Share

Recommended Posts

Please ignore my question below (unless you have a genius idea to do just what I asked;-)), I realised I can do the same with an additional paramter in query string...|-)Is it possible to create an array for comparison from a query before actually have the while loop? I need to compare all file_names retrieved from query ($file2) with the current page id ($id) before I actually loop through all rows... I need them both, once for comparison and once for display of all file_names in listing. I need to do this to have a nav-bar not collapsed when user selects sub-item.

$subQuery = "SELECT page_id, parent_id, file_name, heading FROM content WHERE parent_id = $main ORDER BY list ASC";$subResult = mysqli_query ($dbc, $subQuery);if (mysqli_num_rows($subResult) > 0 && ($file==$id || $file2==$id)) {echo "<ul>";while ($row = mysqli_fetch_array ($subResult, MYSQLI_ASSOC))	{$file2 = $row['file_name'];echo $file2;

Hope I make sense... Also, how to you compare $id to all possible values stored in an array?Son

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...