Dropdown Selection for Shopping Basket under the intermediate Picture Dropdown Selection for Shopping Basket under the intermediate Picture
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Dropdown Selection for Shopping Basket under the intermediate Picture

Started by JohannM, February 25, 2019, 11:58:54 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JohannM

Hello all

I have upgraded to v1.6, as well as servers (Including MariaDB upgrade ... Im very irritated)

So ... Stramms original CPGShop is not working anymore ( I am an idiot in php ), and have been using his plugin for many many years.

Right.

In the meantime, I am struggling to get a code working, and maybe someone can help.

I created a database table called cpg_products, and inside I have the ProductID, ProductCode, ProductDescription and ProductPrice.

I need to add the following script to my themes.inc.php page where I want to have this drop down. I found the correct place, but struggled now for a week for the script to work.

Here is my code:

<form action="https://www.vcs.co.za/vvb/login.asp" target="_blank" method="post">
          <br>
          <select name="Prices">
          $link = cpg_db_connect("localhost", "root", "", "cpg_products");
          $sql = "SELECT cpg_products ProductCode, ProductDescription, ProductPrice FROM cpg_products";
          $result = cpg_db_query($link, $sql);
          print "<option value='Prices' selected>Please select your products here ...</option>";
          While ($row = cpg_db_fetch_assoc($result))
            {
            print "<option value=" . $row["ProductCode"] . ">" . $row["ProductDescription"] . $row["ProductPrice"]"</option>";
            }
          </select>
          <input type="submit" />
          </form>
          if (!isset($_GET["raw"])) {
            echo "What ?";
          }
          else {
            echo "A new Price has been successfully added!";
          }

Obviously I get a lot of errors.

JohannM

I also tried this script


include('include/init.inc.php');
$products = cpg_db_query("SELECT cpg_products ProductCode, ProductDescription, ProductPrice FROM cpg_products order by ProductID");

echo '<select name="products" value="">Please select your product here</option>';

foreach ($products) as $row){

echo '<option value=$row[ProductID]>$row[ProductCode]</option>';

}

echo '</select>';

JohannM

Hello Again

I managed to get a single page "kindoff" working pulling ONLY the first row of data from the table.

1. I only get the very first row of date (Product Code, Description, Currency and Price), but not the rest ( and I have 4 listed);
2. If I put this code in "mythemes/themes/theme.php page I do not see any of the dropdown

Any help would be great.

Thanx

<?php
mysql_connect("localhost", "ysf_AdmNP", "+[}7NO?Vn[&L") or
    die("Could not connect: " . mysql_error());
mysql_select_db("ysf_NEWPUB");

$result = mysql_query("SELECT * FROM cpg_products");
$title = mysql_query("SELECT title FROM cpg_pictures");

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    $P1 = $row["ProdID"]; //PRODUCT UNIQUE ID
    $P2 = $row["pc"]; //PRODUCT CODE
    $P3 = $row["pd"]; //PRODUCT DESCRIPTION
    $P4 = $row["up"]; //UNIT PRICE
    $P5 = $row["c"]; //CURRENCY
    $P6 = $row["v"]; //VAT
    $P7 = $row["u"]; //RETURN URL AFTER BASKET
    $P8 = $row["uid"]; //MERCHAND NUMBER
    $P9 = $row["ma"]; //MERCHANT ADDRESS
   
   
echo <<< EOT
<form name="ccform" method="post" action="$P9" target="_blank">
<select name="Products" class="">
<option value="pick">Please select your product here to add to basket</option>
$result = mysql_query("SELECT * FROM cpg_products");
$row = mysql_num_rows($result);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
<option value="pick">{$P2} - {$P3} - {$P5} {$P4}</option>
<input type="hidden" name="c" value="{$P5}">
<input type="hidden" name="v" value="{$P6}">
<input type="hidden" name="up" value="{$P4}">
<input type="hidden" name="pd" value="{title}::{$P3}">
<input type="hidden" name="pc" value="{$P2}">
<input type="hidden" name="u" value="{$P7}">
<input type="hidden" name="uid" value="{$P8}">
<font face="Verdana" style="font-size: 8pt"><b><br></b><br></font>
<a onclick="myFunction()"><input class="button" type="submit" value=" ADD TO CART " /></a>
</select>
</form>
<script>
function myFunction() {
  window.open("{$P9}", "_blank", "directories=no,titlebar=no,location=no,status=no,menubar=no,toolbar=no,scrollbars=no,resizable=no,top=100,left=500,width=715,height=550");
}
</script>

EOT;

mysql_free_result($result);
mysql_data_seek($result, 0);
}

?>