Jump to content

Access query data before while loop?


son

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...