<?php
//CONNECTS TO YOUR DATABASE (MODIFY TO YOUR SETTINGS)
mysql_connect("localhost", "root", "");
$db = 'library';
$table = 'titles';
$alpha = array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
//LISTS TITLE IN ALPHABETICAL ORDER UNDER EACH LETTER
foreach($alpha as $a){
$q = mysql_query("SELECT * FROM $db.$table WHERE title LIKE '$a%'");
$n = mysql_num_rows($q);
//EXCLUDES LETTER IF THERE TITLES THAT START WITH IT
if($n){
echo '<b style="font-size:20px">'.$a.'</b><br><br>';
while($r=mysql_fetch_array($q)){
echo $r["title"].'<br>';
}
echo '<br>';
}
}
?>
CREATE TABLE `titles` (
`title` VARCHAR ( 100 ) NOT NULL
) ENGINE = MYISAM;
INSERT INTO titles VALUES ('Alpha'), ('Betical'), ('Order'), ('Demo'), ('Demo2'), ('Demo3', 'Indexing');
Subscribe to:
Post Comments (Atom)
Popular Posts
-
Variables are important in every programming language — and it’s no different in PHP. Variables give developers the possibility of temp...
-
What? Hide the .php extension of your PHP files in the URL of your site address. Instead of: http://www.example.com/page.php Visitors to ...
-
Questions : 1 Who is the father of PHP ? Answers : 1 Rasmus Lerdorf is known as the father of PHP. Questions : 2 What is the...
-
Change Db settings here C:\xampp\htdocs\modx\core\xpdo\xpdo.class Line 2920 $this->config['dsn']= $dsn; $this->con...
-
<form action="" name="" method="post"> <p><b>user:</b> <input type="text...
-
Redirection is process of forwarding one URL to a different URL. There are three main kinds of redirects online; 301, 302 and meta refres...
-
Questions : 1 What is database or database management systems (DBMS)? and - What’s the difference between file and database? Can files...
-
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script...
-
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Add More Elements...
No comments:
Post a Comment
Thank you for your Comment....