Why would this Count create two of each?
Posted: Tue May 09, 2017 5:04 am
Code: Select all
$primaryromancode = isset($_POST['primaryromancode']) ? $_POST['primaryromancode'] : null;
$romancode1 = isset($_POST['romancode1']) ? $_POST['romancode1'] : null;
$romancode2 = isset($_POST['romancode2']) ? $_POST['romancode2'] : null;
$romancode3 = isset($_POST['romancode3']) ? $_POST['romancode3'] : null;
$romancode4 = isset($_POST['romancode4']) ? $_POST['romancode4'] : null;
$romancode5 = isset($_POST['romancode5']) ? $_POST['romancode5'] : null;
$romancode6 = isset($_POST['romancode6']) ? $_POST['romancode6'] : null;
$romancode7 = isset($_POST['romancode7']) ? $_POST['romancode7'] : null;
$romancode8 = isset($_POST['romancode8']) ? $_POST['romancode8'] : null;
$romancode9 = isset($_POST['romancode9']) ? $_POST['romancode9'] : null;
$romancode10 = isset($_POST['romancode10']) ? $_POST['romancode10'] : null;
$romancode11 = isset($_POST['romancode11']) ? $_POST['romancode11'] : null;
$romancode12 = isset($_POST['romancode12']) ? $_POST['romancode12'] : null;
$count = 0;
$countcodes = 0;
while ($count <= 11)
{
$count ++;
echo "<font color='#ff0000'>$count</font>";
$romancodefind = ${'romancode' . $count};
$query = "SELECT title, photoprimary, price, romancode FROM products WHERE romancode =:romancodefind";
$result = $pdo->prepare($query);
$result->execute(array(':romancodefind' => $romancodefind));
while ($row = $result->fetch(PDO::FETCH_OBJ))
{
echo "<div style='width: 20%; float: left'><img src='/images/productphotos/$row->photoprimary' style='width: 100%' />$row->title<br/>$row->price<Br/>($romancodefind)</div>";
$countcodes ++;
}
echo "<font color='#ff0000'>$count</font>";
}We are creating bundles of products, so we are posting up to 12 store codes, and a primary code. Hitting save.
Then it turns over, and shows you each product that has been saved.
But this is producing loads of them, and I cannot see why.