Thursday, March 31, 2011

Re: Change an existing variable to another existing variable value????

you are in the wrong group, sir! :)

On 31 Mrz., 23:32, "mae...@yahoo.com" <mae...@yahoo.com> wrote:
> How do I change an existing variable value to another variable value
> that a user selected from a drop down menu?  I have a dropdown that
> allows a user to select an amount based on ounces.   The shopping cart
> was set up to take the variable $price into the cart.  In the
> database, I have $price, $price1, $price2, $3price.  If the user
> selects $price2 from the dropdown, I need the $price variable to
> change to what is inside $price2.   I know I need some type of case of
> switch, but I do not know how to do that so that it changes
> $price?     Any help greatly appreciated.....
>
> <?php
> // Check to see the URL variable is set and that it exists in the
> database
> if (isset($_GET['id'])) {
>         // Connect to the MySQL database
>     include "storescripts/connect_to_mysql.php";
>         $id = preg_replace('#[^0-9]#i', '', $_GET['id']);
>         // Use this var to check to see if this ID exists, if yes then get
> the product
>         // details, if no then exit this script and give message why
>         $sql = mysql_query("SELECT * FROM products WHERE id='$id' LIMIT 1");
>         $productCount = mysql_num_rows($sql); // count the output amount
>     if ($productCount > 0) {
>                 // get all the product details
>                 while($row = mysql_fetch_array($sql)){
>                          $product_name = $row['product_name'];
>                          $price = $row['price'];
>                          $price1 = $row['price1'];
>                          $price2 = $row['price2'];
>                          $price3 = $row['price3'];
>                          $oz = $row['oz'];
>                          $oz1 = $row['oz1'];
>                          $oz2 = $row["oz2"];
>                          $oz3 = $row["oz3"];
>                          $details = $row["details"];
>                         }
>
>         } else {
>                 echo "That item does not exist.";
>             exit();
>         }
>
> } else {
>
>         echo "Data to render this page is missing.";
>         exit();
>
> }
>
> ?>
> <?php
>
> mysql_close();
> ?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> <title><?php echo $product_name; ?></title>
> <link rel="stylesheet" href="style/style.css" type="text/css"
> media="screen" />
> <style type="text/css">
> <!--
> a:link {
>         text-decoration: none;}
>
> a:visited {
>         text-decoration: none;}
>
> a:hover {
>         text-decoration: none;}
>
> a:active {
>         text-decoration: none;}
>
> -->
> </style></head>
> <body>
> <div align="center" id="mainWrapper">
>   <?php include_once("templates/template_header.php");?>
>   <div id="pageContent">
>   <table width="100%" border="0" cellspacing="0" cellpadding="5">
>   <tr>
>     <td width="19%" valign="top"><img src="inventory_images/<?php echo
> $id; ?>.jpg" width="188" height="188" alt="<?php echo $product_name; ?>" />
>
>       <a href="inventory_images/<?php echo $id; ?>.jpg">View Full Size
> Image</a></td>
>     <td width="81%" valign="top"><h2><?php echo $product_name; ?></h2>
>       <h1>
>                 <label>Please select a amount</label>
>         <select name="price"id="price">
>                 <option value="">Choose</option>
>                 <option value="price1"><?php echo $price1 ."  "?><?php echo  $oz1  ?></option>
>
>                 <option value="price2"><?php echo $price2 ."  "?><?php echo  $oz2  ?></option>
>
>                 <option value="price3"><?php echo $price3 ."  "?><?php echo  $oz3  ?></option>
>
>                         </select>
>           </h1>
>           <h1><?php echo $details; ?></h1>
> <br />
>               <form id="form1" name="form1" method="post"
> action="cart.php">
>         <input type="hidden" name="pid" id="pid" value="<?php echo
> $id; ?>" />
>         <input type="submit" name="button" id="button" value="Add to
> Shopping Cart" />
>       </form>      </td>
>     </tr>
> </table>
>   </div>
>   <?php include_once("templates/template_footer.php");?>
> </div>
> </body>
> </html>

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: