How would I go about adding numbers in front of my results (ie: 1. blah, blah, blah 2. blah, blah, blah and so on) This wasn't covered in the course I took so I'm not sure where to start but I'm going to assume it belongs in this section: while($row = mysql_fetch_object($result)){
<?php
// Full-Text Search Example
// Connect to the database.
require_once ('./includes/mysql_connect.php'); //connect to database
$searchwords = mysql_escape_string($_GET['words']);
//Records to display per page.
$display = 10;
//Check if the number of required pages has been determined.
if (isset($_GET['np'])) { //Already been determined.
$num_pages = $_GET['np'];
} else { //Need to determine.
// Count the number of records
$query = "SELECT COUNT(*) FROM master_list WHERE MATCH(album) AGAINST('$searchwords') ORDER BY song_id";
$result = @mysql_query ($query);
$row = mysql_fetch_array ($result, MYSQL_NUM);
$num_records = $row[0];
//calculate number of pages.
if ($num_records > $display) {
$num_pages = ceil($num_records/$display);
} else {
$num_pages = 1;
}
} //end of np if.
//where to start returning results.
if (isset($_GET['s'])) {
$start = $_GET['s'];
} else {
$start = 0;
}
$sql = "SELECT song_id, title, album, writer FROM master_list WHERE MATCH(album) AGAINST('$searchwords')ORDER BY album LIMIT $start, $display";
$result = mysql_query($sql) or die (mysql_error());
while($row = mysql_fetch_object($result)){
echo '<font size="-1">Title: '.stripslashes(htmlspecialchars($row->title)).'<br /></font>';
echo '<font size="-1">Album: '.stripslashes(htmlspecialchars($row->album)).'<br /></font>';
echo '<font size="-1">Writer: '.stripslashes(htmlspecialchars($row->writer)).'<br /></font>';
echo '<hr size="-1" />';
}
// Make the links to other pages, if necessary.
if ($num_pages > 1) {
echo '<br /><p>';
// Determine what page the script is on.
$current_page = ($start/$display) + 1;
// If it's not the first page, make a Previous button.
if ($current_page != 1) {
echo '<a href="searchalbum.php?s='.($start - $display).'&np=' .$num_pages. '&words=' .$searchwords .'">Previous</a> ';
}
// Make all the numbered pages.
for ($i = 1; $i <= $num_pages; $i++) {
if ($i != $current_page) {
echo '<a href="searchalbum.php?s='.(($display * ($i - 1))).'&np=' .$num_pages. '&words=' .$searchwords.'">'.$i.'</a> ';
} else {
echo $i.' ';
}
}
// If it's not the last page, make a Next button.
if ($current_page != $num_pages) {
echo '<a href="searchalbum.php?s='.($start + $display).'&np=' .$num_pages. '&words=' .$searchwords.'">Next</a> ';
}
echo '</p>';
}
// End of links section.
?>