Hi All
Previous issue resolved although was struggling with javascript link to open new small window and have ?id showing
Now I have implemented a search form but I enter a search term submit and then I get nothing.
I have in place all records showing to start then to refine i use the search to find the 1 or 2 records, I also want to create buttons to press for showing all records which are eg Xbox 360, PS3
How do you assign multiple queries one per button
<?php
$page_title = 'View the Current Users';
include ('includes/header.html');
// Page header:
echo '<form action="edit_title.php" method="get">
<table>
<tr>
<td>Search Database :-</td>
<td><input type="text" name="Search" value="Search"/></td>
<td><input type="submit" value="Search" /></td>
</tr></table></form>';
echo '<h1>Edit Game Records</h1>';
require_once ('mysqli_connect.php'); // Connect to the db.
$Search = $_POST['Search'];
trim($Search);
if (!$Search){
echo 'Please enter a search term.';
if (get_magic_quotes_gpc())
{
$Search = addslashes($Search);
}
$query = "select * from Products where Game_Title like '%".$Search."%'";
$result = $dbc->query($query);
/*number of rows found*/
$num_results = $result->num_rows;
echo '<p>There are '.$num_results.' Games located:</p>';
/*loops through results*/
for ($i=0; $i <$num_results; $i++)
{
$num_found = $i + 1;
$row = $result->fetch_assoc();
//echo "$num_found. ".($row['tablerow'])."
//";
}
/*free database*/
$result->free();
// Number of records to show per page:
$display = 25;
// Determine how many pages there are...
if (isset($_GET['p']) && is_numeric($_GET['p'])) { // Already been determined.
$pages = $_GET['p'];
} else { // Need to determine.
// Count the number of records:
$q = "SELECT COUNT(SKU_ProductID) FROM Products";
$r = @mysqli_query ($dbc, $q);
$row = @mysqli_fetch_array ($r, MYSQLI_NUM);
$records = $row[0];
// Calculate the number of pages...
if ($records > $display) { // More than 1 page.
$pages = ceil ($records/$display);
} else {
$pages = 1;
}
} // End of p IF.
// Determine where in the database to start returning results...
if (isset($_GET['s']) && is_numeric($_GET['s'])) {
$start = $_GET['s'];
} else {
$start = 0;
}
// Make the query:
$q = "SELECT * FROM Products ORDER BY Game_Title ASC LIMIT $start, $display";
$r = @mysqli_query ($dbc, $q); // Run the query.
// Count the number of returned rows:
//$num = mysqli_num_rows($r);
//if ($num > 0) { // If it ran OK, display the records.
// Print how many users there are:
// echo "<p>There are currently $num Games entered into database.</p>\n";
// Table header.
echo '<table align="center" cellspacing="3" cellpadding="3" width="100%">
<tr><td>Edit</td><td>Delete</td><td align="left"><b>SKU ID</b></td><td align="left"><b>Game Title</b></td><td align="left"><b>Platform</b></td><td align="left"><b>Genre</b></td><td align="left"><b>Supplier</b></td><td align="left"><b>Supplier Price</b></td></tr>
';
// Fetch and print all the records:
$bg = '#eeeeee'; // Set the initial background color.
$bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch the background color.
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
echo '<tr bgcolor="' . $bg . '"><td align="left"><a href="edit_title.php?id' . $row['SKU_ProductID'] . ' ">Edit</a></td><td></td><td align="left">' . $row['SKU_ProductID'] . '</td><td align="left">' . $row['Game_Title'] . '</td><td align="left">' . $row['Platform'] . '</td><td align="left">' . $row['Genre'] . '</td><td align="left">' . $row['Supplier'] . '</td><td align="left">£' . $row['Supplier_Price'] . '</td></tr>
';
}
echo '</table>'; // Close the table.
mysqli_free_result ($r); // Free up the resources.
} else { // If no records were returned.
echo '<p class="error">There are currently no registered users.</p>';
}
mysqli_close($dbc); // Close the database connection.
// Make the links to other pages, if necessary.
if ($pages > 1) {
// Add some spacing and start a paragraph:
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="view_users.php?s=' . ($start - $display) . '&p=' . $pages . '">Previous</a> ';
}
// Make all the numbered pages:
for ($i = 1; $i <= $pages; $i++) {
if ($i != $current_page) {
echo '<a href="view_users.php?s=' . (($display * ($i - 1))) . '&p=' . $pages . '">' . $i . '</a> ';
} else {
echo $i . ' ';
}
} // End of FOR loop.
// If it's not the last page, make a Next button:
if ($current_page != $pages) {
echo '<a href="view_users.php?s=' . ($start + $display) . '&p=' . $pages . '">Next</a>';
}
echo '</p>'; // Close the paragraph.
} // End of links section.
include ('includes/footer.html');
?>