Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dynamic select list: link to another page

New Here ,
Sep 07, 2012 Sep 07, 2012

Hi

Have following dynamic select list at the bottom in "product.php" page (www.dolls.com.sg)

<div id="selectcat">

  <select name="Categories">

    <?php

do { 

?>

    <option value="<?php echo $row_rsCategories['categoryName']?>"<?php if (!(strcmp($row_rsCategories['categoryName'], $row_rsCategories['categoryName']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rsCategories['categoryName']?></option>

    <?php

} while ($row_rsCategories = mysql_fetch_assoc($rsCategories));

  $rows = mysql_num_rows($rsCategories);

  if($rows > 0) {

      mysql_data_seek($rsCategories, 0);

   $row_rsCategories = mysql_fetch_assoc($rsCategories);

  }

?>

  </select>

My target is, whenever a visitor clicks on a category in the pull down menu, he is forwarded to the respective "categories.php" page.

How can I do that?

Thanks

Helmut

TOPICS
Server side applications
1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Sep 08, 2012 Sep 08, 2012

Change your code to this:

<div id="selectcat">

<form method="get" action="categories.php">

  <select name="Categories">

    <?php

do { 

?>

    <option value="<?php echo $row_rsCategories['categoryName']?>">

    <?php echo $row_rsCategories['categoryName']?></option>

    <?php

} while ($row_rsCategories = mysql_fetch_assoc($rsCategories));

  $rows = mysql_num_rows($rsCategories);

  if($rows > 0) {

      mysql_data_seek($rsCategories, 0);

   $row_rsCategories = mysql_fetch_assoc($rsCategories);

  }

?>

  </select>

...
Translate
LEGEND ,
Sep 07, 2012 Sep 07, 2012

You just need to add some javascript to convert that drop down into a Jump Menu:

http://www.smartwebby.com/web_site_design/jump_menus.asp

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 08, 2012 Sep 08, 2012

But my target is that with every menu item clicked the visitor is linked to the same "categories.php" page with the respective content from the database for that menu item. I don't see how I can do it with jump menu.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 08, 2012 Sep 08, 2012

Change your code to this:

<div id="selectcat">

<form method="get" action="categories.php">

  <select name="Categories">

    <?php

do { 

?>

    <option value="<?php echo $row_rsCategories['categoryName']?>">

    <?php echo $row_rsCategories['categoryName']?></option>

    <?php

} while ($row_rsCategories = mysql_fetch_assoc($rsCategories));

  $rows = mysql_num_rows($rsCategories);

  if($rows > 0) {

      mysql_data_seek($rsCategories, 0);

   $row_rsCategories = mysql_fetch_assoc($rsCategories);

  }

?>

  </select>

  <input type="submit" value="View Dolls">

</form>

</div>

In categories.php, use $_GET['Categories'] to filter the recordset.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 09, 2012 Sep 09, 2012
LATEST

Dear David,

Thanks for the code. It is working now!

Helmut

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines