
Originally Posted by
clint6998
That's strange that it cuts off at "U". My phone sees it all but it also cuts off the second column instead of floating left like it should. Any ideas why it would float from 3 columns to 2 but not 2 to 1?
Also, I want to put a line "|" between each letter. I can do that but them it puts one after the last one. Can you help on how to NOT put on after the last one?
Also, still trying to replace the numbers with a #. Could you help with the script? I cant write it but something like "if first character does not start with a letter, then show "#" and then list all numerical values under the "#"?"
The issue, and not sure how/where you are adding the pipe character |, but if you wrap it in an if statement such that:
Code:
if ($i < (last value of applicable $i - 1)) {
So, I've addressed three issues in one below, doesn't take care of any "float" issues, though that is likely more because of the various CSS that would probably be involved. Currently the display is linear from left to right, instead of being columnar with each column being in its own div/span or each item being in its own container like an odd/even scenario and therefore can't slide into the list to maintain alphabetic order in a single column. BTW, my second column is also cut short on my cell phone. Anyways, The below "highlighted" code is what has been changed:
Code:
<?php
echo '<div id="alphanumericWrapper"><a name="attop">';
echo 'Manufacturers ';
echo '<a href="'. $_SERVER['REQUEST_URI'] . '#hash">#</a>';
for ($i=65; $i<91; $i++) {
echo '|';
echo '<a href="'. $_SERVER['REQUEST_URI'] . '#' . chr($i).'">' . chr($i) . '</a>';
}
echo '</a></div>';
echo '<br class="clearBoth" />';
$manufacturers_query = "SELECT distinct manufacturers_id, manufacturers_name FROM " . TABLE_MANUFACTURERS . " ORDER BY manufacturers_name";
$manufacturers = $db->Execute($manufacturers_query);
$numeric_displayed = false;
while (!$manufacturers->EOF) {
if (!is_numeric(strtoupper(substr($manufacturers->fields['manufacturers_name'], 0, 1))) && $initial !== strtoupper(substr($manufacturers->fields['manufacturers_name'], 0, 1))) {
$initial = strtoupper(substr($manufacturers->fields['manufacturers_name'], 0, 1));
echo '<br class="clearBoth" />';
echo '<a name="'.$initial.'" class="bold bigger defaultColor">' . $initial . '</a>';
echo ' <a href="'.$_SERVER['REQUEST_URI'] . '#attop">Back to Top</a>';
echo '<br class="clearBoth" />';
} elseif (!$numeric_displayed && is_numeric(strtoupper(substr($manufacturers->fields['manufacturers_name'], 0, 1)))) {
$initial = strtoupper(substr($manufacturers->fields['manufacturers_name'], 0, 1));
echo '<br class="clearBoth" />';
echo '<a name="hash" class="bold bigger defaultColor">#</a>';
echo ' <a href="'.$_SERVER['REQUEST_URI'] . '#attop">Back to Top</a>';
echo '<br class="clearBoth" />';
$numeric_displayed = true;
}
echo '<div style="width: 33.3%; float: left;"><a href="' . zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . (int) $manufacturers->fields['manufacturers_id'], $request_type) . '">' . $manufacturers->fields['manufacturers_name'] . '</a></div>';
$manufacturers->MoveNext();
}
echo '<br class="clearBoth" />';
?>
This resequenced the # symbol to the beginning (such businesses appear first), which allows the pipe symbol (|) to be inserted before the next "letter" and therefore there is never a symbol that follows another letter, it always precedes the next letter. Then it (untested) displays the # symbol one time with all of the businesses that begin with a number, then once a letter is encountered, it switches to displaying the original code with each letter being displayed followed by the manufacturers that begin with that letter until the end. Also, have added a Back to Top link that should return back to the list of characters and is displayed adjacent to each main divider character.