Here is the code I have so far. It extracts the 2nd word of a set of model numbers. Trouble is with this is there are multiple same model number results. How can I acquire just the one result? I can’t use GROUP on the statement as the names can be different yet the model number the same. I somehow need to apply a limit to the rest of the code.
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$querytp1 = $_GET['querytp1'];
echo $querytp1;
// Make a MySQL Connection
include('../ukshop/con.php');
$conDB = mysqli_connect($db_host, $db_username, $db_password,$db_name)or die('Error: Could not connect to database.');
echo '<br>Con Made<br>';
if ($querytp1 > "") {
$statement = mysqli_query($conDB,"SELECT * from affiliSt_products1 WHERE prodName like '%$querytp1%' AND prodCategory like '%television%' order by prodName ");
if (mysqli_num_rows($statement) != 0) {
// displaying records.
while ($row = mysqli_fetch_array($statement)) {
$prodName = $row['prodName'];
$tagWords = $prodName;
$tagWords = explode(" ", $tagWords);
if ($tagWords[0] > "") {
$querytp7 = $tagWords[1];
}
if (strpos($querytp7, 'U') === 0) {
// It starts with 'U'
echo '<div style="float: left">';
echo 'Model: ';
echo '<a href="index.php?querytp1=';
echo $querytp7;
echo '">';
echo $querytp7;
echo '</a>';
echo '</div>';
echo '<div style="float: left; padding-left: 10px;">';
echo 'Screen Size: ';
echo substr("$querytp7", 2, 2); // TV Size
echo '</div>';
echo '<div style="clear: both;"></div>';
}
}
}
}
Cheers