I changed the db info and added the two date php variables in but I am just getting a blank white page with no errors?
Code:
<?php
ini_set('display_startup_errors',1);
ini_set('display_errors',1);
error_reporting(-1);
$dbConn = mysqli_connect("localhost" , "dbname", "password", "dbname") or die("Check connection parameters!");
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Paginate data</title>
<script type="text/javascript">
function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}
document.onkeypress = stopRKey;
</script>
<link rel="stylesheet" type="text/css" media="screen" href="css/styles.css" />
<link rel="stylesheet" type="text/css" href="css/tcal.css" />
<script type="text/javascript" src="js/tcal.js"></script>
</head>
<body>
<?php include("nav-menu.php"); ?>
<div id="logo">
<img src="images/logo/it-done-right.jpg" alt="" title="">
</div>
<?php
$data = [];
if (isset($_GET["rows"])) { // If variable 'rows' is in the URI, then use it.
$per_page = $_GET["rows"];
} else {
$per_page = 5;
}
if (isset($_GET["d1"])): // If variable 'pfx' is in the URI, then use it.
$d1 = $_GET["d1"]; // Otherwise go to bottom of page and just display
// 'New Search'.
if (isset($_GET["d2"])): // If variable 'pfx' is in the URI, then use it.
$d2 = $_GET["d2"]; // Otherwise go to bottom of page and just display
// 'New Search'.
echo '<h2>Paginate records from database</h2>';
if (isset($_GET["page"])) { // If variable 'page' is in the URI, then use it,
$page = $_GET["page"]; // as this is a recursive call.
} else {
$page = 1; // Otherwise set to page zero.
}
if (isset($_GET["size"])) { // if variable 'size' is in the URI, then use it.
$size = $_GET["size"];
} else {
$query = "SELECT id FROM purchased_software WHERE sales_month BETWEEN LIKE '%".$d1."%' AND '%".$d2."%' ORDER BY id";
$result = mysqli_query($dbConn, $query);
if ($result) {
$size = ceil((mysqli_num_rows($result))/$per_page);
}
}
$start_from = ($page - 1) * $per_page;
$result = mysqli_query($dbConn, "SELECT * FROM purchased_software WHERE sales_month BETWEEN LIKE '%".$d1."%' AND '%".$d2."%' LIMIT $start_from, $per_page");
if ($result) {
$data = mysqli_fetch_all($result, MYSQLI_ASSOC);
}
?>
<table>
<thead>
<tr>
<th>Software ID</th>
<th>Customer PayPal Email</th>
<th>Ebay Username</th>
<th>Sales Date</th>
<th>Software Title</th>
<th>Quantity</th>
<th>Total Sale</th>
<th>Ebay Fees</th>
<th>PayPal Fees</th>
<th>Cost Price</th>
<th>Profit</th>
<th>Notes</th>
<th>Status</th>
<th>Sold By</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
echo '<p><strong>Page '. $page .' of '.$size.'.</strong></p>';
foreach ($data as $row): ?>
<tr>
<td><a href="view-specific-software-sale.php?id=<?= $row['id']; ?>"><?php echo $row['id']; ?></a></td>
<td><?php echo $row['customer_pp_email']; ?></td>
<td><?php echo $row['ebay_username']; ?></td>
<td><?php echo date("d/m/Y", strtotime($row['sales_month'])); ?></td>
<td><?php echo $row['software_title']; ?></td>
<td><?php echo $row['quantity']; ?></td>
<td><?php echo $row['total_sale']; ?></td>
<td><?php echo $row['ebay_fees']; ?></td>
<td><?php echo $row['paypal_fees']; ?></td>
<td><?php echo '£' . $row['software_cost']; ?></td>
<td><?php echo '£' . $row['profit']; ?></td>
<td><?php echo substr($row['notes'], 0, 25); ?></td>
<td><?php echo $row['status']; ?></td>
<td><?php echo $row['sold_by']; ?></td>
<td><a href="add-update-software-sales.php?id=<?= $row['id']; ?>">Edit</a></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php
$urld1 = urlencode($d1);
$urld2 = urlencode($d2);
if($size > 1) {
echo '<p><br /><br />';
for($i=1; $i<=$size; $i++) {
echo '<button style="margin-right:0.5em;"><a href="search-info.php?page='.$i.'&size='.$size.'&rows='.$per_page.'&d1='.$urld1.'&d2='.$urld2.'">'.$i.'</a></button>';
}
}
echo '<h4>New Search</h4>';
else: // End of 'if (isset($_GET["pfx"])):' from line 43.
echo '<h2>New Search</h2>';
endif; // End of 'if (isset($_GET["pfx"])): else:' on line 43.
?>
<form action="search-info.php" method="get">
<p>From : <input type="text" name="d1" class="tcal" value="" /></p>
<p>To: <input type="text" name="d2" class="tcal" value="" /></p>
<p>Rows per page: <input type="text" name="rows" value="10" maxlength="4" /></p>
<p><input type="submit" /></p>
</form>
</body>
</html>
Bookmarks