-
1. Re: Creating buttons for a search page
SnakEyez02 Apr 14, 2013 8:33 AM (in response to whatalotofrubbish)I tried searching through your site and I don't see the drop-downs you are referring to. Drop-downs work just fine on phones from Android and iOS. I've never experienced any issues with them. What issue are you experiencing with them?
As for the other values, if you want $b to appear where your "A" is, just do <?php echo $b; ?> where the "A" is.
Unfortunately, we cannot see syntax issues as PHP is processed prior to the page load so we would need you to post the source code if you wish for us to help with a syntax error.
-
2. Re: Creating buttons for a search page
whatalotofrubbish Apr 15, 2013 7:11 AM (in response to SnakEyez02)One of the drop downs is at http://tyneships.co.uk/phpfiles/findall.php5 which lists all the 3K+ records. All others appear on the Search menu item on the left of most pages other than the splash page.
I find these very dificult to use on a mobile, without having to zoom in.
It occurred to me that creating a set of buttons would be very helpful to users, as the whole set can be filtered using the same numberof pages that are needed using a drop down list.
The grid below is a result of a quick search of all records listing the first letters of all types in the data, and displaying them as buttons.
Notice that I, J, Q, X and Z do not appear in the grid, as there are no types in the database beginning with these letters.
As a result, a click on any of these buttons should produce valid data. No error checking is yet in place.
Above is my first attempt to create the buttons on a grid using php. Ignore the uU buttons - garbage in the data file now sorted on line.
The working source code is shown below, without the data file access code or css. The original code that I used suffered from logic errors and syntax errors, now fixed.
<body>
<form action="get_types.php" method="get" name="type_form" target="_self">
<table border="1" cellpadding="2" cellspacing="2" class="purple">
<?php
$rowcount = 1;
do {
$b= ($row_Recordset1['type']); // Read the record
$b = left("$b",1); //get its first character
if ($old <> $b) { // then we have found a new letter so print it as a button
echo '<td> <input type="button" name="button" value="' . $b . '" </td> ' ;
if ($rowcount <=6) { // count the columns in the row. If less than 6 add 1
$rowcount++;
}
$old = $b; //reset the old character to the new one
}
if ($rowcount == 6) {// if its 6, we are at the end of the row
echo '<tr>'; // end the row
$rowcount = 1;//reset it to 1
}
?>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
</form>
<span>
Click the 1st letter of the type group</span>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
This code generates the buttons in a grid at the correct size for a,320x300 phone.
Now I have the buttons set up, I need to get them to do something - like submit the form.
This needs a bit more thought, as usually you only have one button doing the sending.
I suppose I could place a form round every button, but there must be a better way. All suggestions welcomed.
Once this problem is overcome, the button clicked on should send its letter to the next page, which would display a list of all types beginning with the chosen letter, and clicking on these then links to a sliding photo display of all the ships in the type group.Easier to use than a drop down list, but the logic and coding from scratch is more difficult.
Howard Walker
-
3. Re: Creating buttons for a search page
whatalotofrubbish Apr 15, 2013 8:26 AM (in response to whatalotofrubbish)Quote "
This needs a bit more thought, as usually you only have one button doing the sending.
I suppose I could place a form round every button, but there must be a better way. "quote
Just found the answer in the <button> command in html5
Replace this:
echo '<td> <input type="button" name="button" value="' . $b . '" </td> ' ;
With this:
echo '<td><button name = "submit" value="'. $b . '"> ' .$b.' </button> </td> ';
If you don't use "type = button", all buttons are submit buttons.



