I am trying to port my code from PHP/MySQL to MySQLi but cant seem to get it to work, can any body see where I am going wrong??
The Query Works OK but when I try to output the index all buttons are active, when only the button with the letters from the SELECT result should be active.
Using latest PHP, MySQLi and BootStrap
[CODE]<?php
/* SELECT DISTINCT FIRST LETTERS*/
$sqll=”SELECT DISTINCT LEFT(lnk_topic, 1) as letter FROM `lnk_topics` ORDER BY letter”;
if(!$resultl = $mysqli->query($sqll)){
die(‘There was an error running the query [‘ . $mysqli->error . ‘]’);
}
/* PERFORM QUERY */
$rowl = $resultl->fetch_array();
/* CONVERT ARRAY TO UPPERCASE FOR COMPARISON*/
$larray=array_map(“strtoupper”, $rowl);
/*LOOP THRU EACH LETTER OF THE ALPHABET */
foreach (range(‘A’, ‘Z’) as $char) {
if(in_array($char,$larray)) {
echo “<a href=’#”.strtoupper($char).”‘ class=’btn btn-info’ role=’button’>”.strtoupper($char).”</a>n”;
}
else
{
echo “<a href=’#’ class=’btn btn-sm btn-disabled’ role=’button’>”.strtoupper($char).”</a>n”;
}
}
echo “<hr>n”;
?>