echo '<a class="bg-danger btn btn-default" href="index.php" '; global $post, $wpdb; if( !isset($_GET['char']) ){ echo ' class="active" '; } echo ' >All</a></li>'; // Select Alphabets and total records $alpha_sql = "select DISTINCT LEFT(title , 1) as firstCharacter, ( select count(*) from products where LEFT(title , 1)= firstCharacter ) AS counter from products order by title asc"; $result_alpha = mysqli_query($wpdb->dbh,$alpha_sql); while($row_alpha = mysqli_fetch_array($result_alpha)){ $firstCharacter = $row_alpha['firstCharacter']; $counter = $row_alpha['counter']; echo '<a class="btn btn-default" href="?char='.$firstCharacter.'" '; if( isset($_GET['char']) && $firstCharacter == $_GET['char'] ){ echo ' class="active" '; } echo ' >'.$firstCharacter.'</a></li>'; } ?> <?php // selecting rows $sql = "SELECT * FROM products where 1"; if( isset($_GET['char']) ){ $sql .= " and LEFT(title,1)='".$_GET['char']."' "; } $sql .=" ORDER BY title ASC"; $result = mysqli_query($wpdb->dbh,$sql); $sno = 1; while($fetch = mysqli_fetch_array($result)){ $title = $fetch['title']; $meaning = $fetch['meaning']; $description = $fetch['description']; ?> <tbody> <tr> <td><?php echo $sno; ?></td> <td><?php echo $title; ?></td> <td><?php echo $meaning; ?></td> <td><?php echo $description; ?></td> </tr> </tbody> <?php $sno ++; } ?> </table>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)