<?php
$link = mysqli_connect("127.0.0.1", "uhifgxlr341ry", "c0guhaptz5u5", "dbobfnwmmcprwn");
if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
$productId = $_GET["product"];
//echo $_GET["searchText"];
$sqlSafeString= mysqli_real_escape_string($link,$_GET["searchText"]);
//echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL; echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;
$sql = "SELECT p.id, p.productName, p.productDescription,v.vendorName FROM products p, vendor_names v WHERE p.productVendor=v.id and (p.productDescription like '%".$sqlSafeString."%') AND DATE(p.productOfferEnd) >= CURDATE() ORDER BY p.productName ASC";
$result = $link->query($sql);
if ($result->num_rows > 0) {
echo '<table cellpadding="2">';
echo '<tr><th scope="col" valign="top" width="25%">Name</th><th scope="col" valign="top" width="40%">Description</th><th scope="col" valign="top" width="25%">Vendor</th></tr>';
$i=0;
// output data of each row
while($row = $result->fetch_assoc()) {
$i++;
$color=($i%2==0)?"#ddd":"#fff";
echo '<tr bgcolor="'.$color.'"><td><a href="index.php/collective-purchasing-agreements-detailed-information?product='. $row['id'].'">'.$row['productName'].'</a></td><td>'.substr($row['productDescription'],0,150). '...</td><td>'.$row['vendorName'].'</td></tr>';
}
echo '</table>';
} else {
echo "No results found.";
}
mysqli_close($link);
?>