title: How to create a dynamic page jump
body: <p>I am trying to create a dynamic page jump.
  I know how to create a page jump for example</p>
  
  <pre><code>&lt;a href="#example"&gt;example&lt;/a&gt;
  &lt;a name="example"&gt;example1&lt;/a&gt;
  </code></pre>
  
  <p>I have a products page that echo's everything out using a string from the database, product category, name and description; and i also have another set of product category names which print separately. I want to match up the product categories so if the user clicks on the category names that are printed separately, the page will jump and take the user to correct start of the page.</p>
  
  <p>like the Deliveroo website. <a href="https://deliveroo.co.uk/menu/london/bloomsbury/mantovani-1946" rel="nofollow">click here</a></p>
  
  <p>At the moment when clicking on the separate category name the page jumps but not to the correct category name. It just keeps jumping to the first category name listed.</p>
  
  <p><strong>My code</strong></p>
  
  <pre><code>mysqli_report(MYSQLI_REPORT_INDEX);
  if (isset($_GET['rest_id'])) {
      $R = $_GET['rest_id'];
      $g_cat = "SELECT * FROM Food_Cat WHERE Resturant_ID = '$R'";
      $runn_g_cat = mysqli_query($dbc, $g_cat);
      mysqli_stmt_execute($runn_g_cat);
      echo("&lt;div id='get_cats'&gt;");
      $iiii=1;
      while ($row_g_cat = mysqli_fetch_array($runn_g_cat)) {
          $Food_Cat_name = $row_g_cat['Food_Cat_name'];
  
          echo("&lt;a id='show_cats' href='#foodcat$iiii'&gt;$Food_Cat_name&lt;/p&gt;");
          $iiii=1;
      }
  }
  </code></pre>
  
  <p>...</p>
  
  <pre><code>while ($row_get_cat = mysqli_fetch_array($run_get_cat)) {
      $category_name = $row_get_cat['Food_Cat_name'];
      $food_id = $row_get_cat['Food_Cat_ID'];
  
      echo("&lt;div id='cat_name' class='cat_name'&gt;");
      echo("&lt;a name='foodcat$iiii' id='categ_nme'&gt;$category_name&lt;/p&gt;");
      echo("&lt;hr id='line'&gt;");
      $iii++;
  }
  </code></pre>
  
  <p>The entire code is very long but works, i have error handlers, sessions are set and the queries work.</p>