Any thoughts will be most welcome.

In PhpMyAdmin and Dreamweaver cs6.

I would like the user of my site to be able to select a category from a list that is populated by PhpMyAdmin and then, his or her selection to reveal all of the items on the database in that category.

The selector is working fine using “selectmenu” and I have the form setup which shows the data using bindings.
How do I connect the two?

Recommended Answers

All 7 Replies

Please show your code.

I do not understand how you expect people to assist in "connecting the two" if you do not show the code to start with

I'm sorry. I thought it was a technique rather than code, I'll attach it right away.

              <div data-role="fieldcontain">
                  <label for="selectmenu" class="select">Type d'événement:</label>
                  <select name="selectmenu" id="selectmenu">
do {  
                    <option value="<?php echo $row_getEvents['eventtype']?>"><?php echo $row_getEvents['eventtype']?></option>
} while ($row_getEvents = mysql_fetch_assoc($getEvents));
  $rows = mysql_num_rows($getEvents);
  if($rows > 0) {
      mysql_data_seek($getEvents, 0);
      $row_getEvents = mysql_fetch_assoc($getEvents);
                  <?php do { ?>
                  <li lang="fr"><br>
                  <span style="font-size: x-large"><?php echo $row_getEvents['eventtype']; ?> <?php echo $row_getEvents['cas']; ?></span><br>
                  <?php echo $row_getEvents['date']; ?><br>
                    <?php echo $row_getEvents['address']; ?>                    <br>
                    <?php echo $row_getEvents['eventdetails']; ?><br>
                    Adulte: <?php echo $row_getEvents['adulte']; ?>  Enfant: <?php echo $row_getEvents['enfant']; ?><br>
                    Contact: <?php echo $row_getEvents['adjoint']; ?>  <?php echo $row_getEvents['surname']; ?> <?php echo $row_getEvents['firstname']; ?><br>
                    Téléphone: <?php echo $row_getEvents['phone']; ?>  Email: <?php echo $row_getEvents['email']; ?><br>
                    Site Internet: <?php echo $row_getEvents['website']; ?> <br>
                    <?php } while ($row_getEvents = mysql_fetch_assoc($getEvents)); ?>

2 ways really

1 is java, that would be an onEvent()

or via a form, user selects the drop down, submits and shazam.

Member Avatar

OK couple of things. You should try to separate the inner workings of an IDE (DW6) from your markup, templates and php code. The code etc should remain independent and be able to work with any environment. As I recall DW had a really horrible way of creating templates and repeating areas etc. Yuk!

ANyway. Your code seems to have a considerable mix of php and html. I'd try to avoid this as it may get difficult to maintain and debug when things aren't working.

Try to keep your html clear of php other than things like echo $variable or the odd 'if' or even a rare 'loop'. If you can hide the bulk of your php obove the Doctype Declaration, you're making it cleaner. Better still would be to stuff your code into functions (or better still class methods - but that may be a step too far at this point) and place them into an include file for use across a number of pages.

Just a thought.

If you are sending form data to the server on every dropdown selection, then you may wish to consider Ajax to avoid whole page refresh every time, so you end up just refreshing the specific data (e.g. a html data table). Again this would clean up the php code from the actual page itself.

As squidge notes 'javascript' can be used to automatically submit the form without the need for a submit button. This sort of thing used to be frowned upon from an accessibility POV, but seems to be common practice these days.

WIth regard to getting the data. You have a couple of options - if you load all the data into a js variable on page load, then it's there to retrieve on dropdown change without involving the server. However, if the data is liable to frequent changes, you don't want 'static data' to be displayed say 10 munites after the page loaded originally, so an Ajax approach (fresh data from the DB on every change) may be more appropriate.

Fantastic! Thank you very much for your help.

Is it okay to simply cut the php and paste it above the Doctype declaration?

Where do I find out about the javascript that will tell the server what the user wants to see and how do I do it?. I feel I ought to add; the website is mostly for the local villages in Le Segala, a huge area in the Midi Pyrenées, to list their various events in the summer. These events fall into categories like "dance", "meal", "fair" and so on. There could be thousands of items on the db so I need visitors to be able to select the type of event that they would like to see instead of wading through piles of inappropriate information. Thank you again for your guidance.

You are so kind, thank you very much. I've been trying to figure this for days.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.