Jump to content

Dubya008

Members
  • Posts

    23
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Dubya008's Achievements

Member

Member (2/5)

0

Reputation

  1. okay So i made the changes that you suggested. It is now deleting 2 of the elements at once. Would I need to rebuild the entire array after I've deleted the element of the array? $Item1=array("ProdID"=>"Hat","Color"=>"Not Needed","Size"=>5); $Item4=array("ProdID"=>"Shirt","Color"=>"Green","Size"=>"L"); $Item2=array("ProdID"=>"Pants","Color"=>"Not Needed","Size"=>"32x32"); $Item3=array("ProdID"=>"Socks","Color"=>"Not Needed","Size"=>"Not Needed"); $NumItems=4; $_SESSION['Cart']=array(1=>$Item1,2=>$Item2,3=>$Item3,4=>$Item4,"NumItems"=>$NumItems); $ItemNum=$_GET['id']; if ($ItemNum=="All"){ //deleting everything in the cart unset($_SESSION['Cart']); } else{ $_SESSION['Cart']['NumItems']--; //taking the number of items down by 1 if(!$_SESSION['Cart']['NumItems']) //checking to see if the number of items is above zero { unset($_SESSION['Cart']); //if the number is above zero then delete the whole variable } else //deleting a specific element of the array { echo "DELETING ".$_GET['id']."<br>"; unset($_SESSION['Cart'][$ItemNum]); }
  2. I am using session variables to keep track of what is in a shopping cart. I can add the items to the cart quite easily enough. But my problem is that I can't delete a specific item in the cart. Below is a summary of what the array looks like $Item1=array("ProdID"=>"Hat","Color"=>"Not Needed","Size"=>5); $Item4=array("ProdID"=>"Shirt","Color"=>"Green","Size"=>"L"); $Item2=array("ProdID"=>"Pants","Color"=>"Not Needed","Size"=>"32x32"); $Item3=array("ProdID"=>"Socks","Color"=>"Not Needed","Size"=>"Not Needed"); $NumItems=4; $TestArray=array("NumItems"=>$NumItems,1=>$Item1,2=>$Item2,3=>$Item3,4=>$Item4); However when I attempt to delete any of the top level elements (1,2,3,4,NumItems), I either end up deleting only the last element (4) or somehow taking out 2 of them. I know that this must be an easy fix but I've looked at it for so long that I can't seem to figure out what the problem is. below is the code that I use to delete the Item from the array $ItemNum=$_GET['item']; if ($ItemNum=="All"){ $ItemNum=$_GET['item']; if ($ItemNum=="All"){ unset($TestArray); unset($TestArray['NumItems']); unset($_SESSION['OrderTotal']); //header("Location:Cart.php?act=view"); } else{ $TestArray['NumItems']=$TestArray['NumItems']-1; if($TestArray['NumItems']<1) { unset($_SESSION['OrderTotal']); unset($TestArray); unset($TestArray['NumItems']); } else { unset($TestArray[$ItemNum]); } Can anyone take a look at this and point me in the correct direction? What I am after is to delete any element of the top array and keep the rest.
  3. yes exactly the same attributes nothing more nothing less. So that I can create a dynamic query that will give me the products that have attribute 25 and 45. Or any other attributes that I need to add
  4. I'm thinking that this may be impossible from the same table. Would anyone with more experience point me in the right direction to even see if this is possible?
  5. Those were all very helpful however none of them returned what I'm looking for. Given the example above here is what I want returned. products 234 & 568 because they have both attributes 23 and 45
  6. I have a table that has numeric values in it id, Product, Attribute It is a "cross-over" table that stores attribute values for products. There can be more than 1 attribute per product: id Product Attribute 1 234 45 2 234 23 3 896 45 4 896 33 5 568 23 6 568 45 7 790 23 I need to create a Query that will return all of the products that have the same attributes. I've tried the following which returns nothing SELECT * FROM ProdAts WHERE Attribute='45' AND Attribute ='23' This returns nothing. I believe that I understand why(No row contains both numbers) If i use an OR instead of an AND i get some Products that have only 1 of the attributes. I'm attempting to pull all products that have the same attributes. Is this possible via SQL?
  7. I'm looking for a method that will return the date for the next 2 weeks in php. I can pull the date but I'm not sure about adding to the date. Can anyone point me in the correct direction?
  8. Thank you for your response. I believe that is exactly what we're doing: using the end-user's address to send the info to our specific address. I've pasted some code that we had from the website designer. Can you tell me if you think that is the reason why it wouldn't work. define('kOptional', true);define('kMandatory', false);error_reporting(E_ERROR | E_WARNING | E_PARSE);ini_set('track_errors', true);function DoStripSlashes($fieldValue) { if ( get_magic_quotes_gpc() ) { if (is_array($fieldValue) ) { return array_map('DoStripSlashes', $fieldValue); } else { return stripslashes($fieldValue); } } else { return $fieldValue; } }function FilterCChars($theString) {return preg_replace('/[\x00-\x1F]/', '', $theString);}function CheckEmail($email, $optional) {if ( (strlen($email) == 0) && ($optional === kOptional) ) { return true;} elseif ( eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email) ) { return true;} else { return false;}}if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {$clientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];} else {$clientIP = $_SERVER['REMOTE_ADDR'];}$FTGFname = DoStripSlashes( $_POST['Fname'] );$FTGLname = DoStripSlashes( $_POST['Lname'] );$FTGCompany = DoStripSlashes( $_POST['Company'] );$FTGEmail = DoStripSlashes( $_POST['Email'] );$FTGWebsite = DoStripSlashes( $_POST['Website'] );$FTGPhone = DoStripSlashes( $_POST['Phone'] );$FTGCity = DoStripSlashes( $_POST['City'] );$FTGState = DoStripSlashes( $_POST['State'] );$FTGPostal = DoStripSlashes( $_POST['Postal'] );$FTGCountry = DoStripSlashes( $_POST['Country'] );$FTGQes1 = DoStripSlashes( $_POST['Qes1'] );$FTGQes2 = DoStripSlashes( $_POST['Qes2'] );$FTGQes3 = DoStripSlashes( $_POST['Qes3'] );$FTGPage=DoStripSlashes( $_POST['page'] );$validationFailed = false;# Fields Validationsif (!CheckEmail($FTGEmail, kMandatory)) { $validationFailed = true; }# Redirect user to the error pageif ($validationFailed === true) {#header("Location: http://lynxfulfillment.com/index.html");echo "<script>location='{$_SERVER['HTTP_REFERER']}'</script>"; }if ( $validationFailed === false ) {# Email to Form Owner $emailSubject = FilterCChars("Lynx Fulfillment Website"); $emailBody = "Fname : $FTGFname\n" . "Lname : $FTGLname\n" . "\n" . "Company : $FTGCompany\n" . "Email : $FTGEmail\n" . "Website : $FTGWebsite\n" . "Phone : $FTGPhone\n" . "City : $FTGCity\n" . "State : $FTGState\n" . "Postal : $FTGPostal\n" . "Country : $FTGCountry\n" . "\n" . "Qes1 : \n" . "$FTGQes1\n" . "\n" . "Qes2 : \n" . "$FTGQes2\n" . "\n" . "Qes3 : \n" . "$FTGQes3\n" . "Site Number : 1\n" . "Page Used : $FTGPage\n" . "IP: $clientip \n" . "index.html"; $emailTo = 'Lynx <[email protected]>'; $emailFrom = FilterCChars("$FTGEmail"); $emailHeader = "From: $emailFrom\n" . "MIME-Version: 1.0\n" . "Content-type: text/plain; charset=\"ISO-8859-1\"\n" . "Content-transfer-encoding: 7bit\n"; mail($emailTo, $emailSubject, $emailBody, $emailHeader); # Redirect user to success pageheader("Location: http://www.lynxfulfillment.com/success.html");}?>
  9. So do you want 2 records per row? Biz 1 info Biz2 biz 3 biz 4
  10. I'm using the php mail function on some forms for our company website. There is reason to believe that they sometimes don't work. Is this a normal behavior for this? We've been "discussing" whether or not they work for about 2 - 3 days and in most instances they do. However we've had 1 person fill them out and then we never received the emails. I was wondering if some of the people that have worked with php for a longtime have ever had any experience with this type of thing happening.
  11. Wow that worked like a charm. Thanks so much for the help guys. My final Query is below. I didn't need the Product Name as that will be already displayed on the screen in other places. SELECT Attributes.Attribute, Products_Attributes.Product FROM Attributes LEFT JOIN Products_Attributes ON Products_Attributes.Attribute = Attributes.id AND Products_Attributes.Product = '1'
  12. KickStart that was helpful and can be used in another spot for something else so Thank you for that. However that wasn't quite what I was looking for. I need to have the following Attribute Product Men's 1 Women's Color 1 Size 1 Fun!! Boring Awesome I don't know if that makes sense to anyone but me. I just want all of the Attriubutes on the left and on the right the specific product that we're looking at.
  13. I have 2 tables Attributes id,Attribute 1,Men's 2,Women's 3,Color 4,Size 5,Fun!! 6,Boring 7,Awesome Products_Attributes id,Product,Attribute 1, 1, 1 2, 1, 4 3, 2, 1 4, 2, 5 5, 1, 3 6, 2, 6 7, 2, 7 I'm trying to pull all of the data from the Attributes table next to all of the data product data for a particular product. I've tried using left joins but am having a tough time with it. So far this is what I have but it is only pull the attributes for the product. SELECT Attributes.Attribute, Products_Attributes.Product FROM Attributes LEFT JOIN Products_Attributes ON Attributes.id=Products_Attributes.Attribute WHERE Products_Attributes.Product ='1' What I am getting is: Attribute,Product Men's, 1 Size, 1 Color, 1 Anyone know how to pull all the Attributes and only one product?
  14. I don't know if this is the correct Forum to post this under but I'm trying to fill the values of a recordset into an array. Here is what I have but it doens't work so far. function fetch($info) { return mysql_fetch_array($info); } $Proddb = new mysql; $Proddb->connect(); $result = $Proddb->query("SELECT * FROM Colors WHERE id = '1'"); $row = $Proddb->fetch($result) foreach ($row as $value) { echo $value. "<br>"; } $Proddb-> close(); The array is outputting everything twice does anyone know why?
  15. HA! I was almost there. That worked perfectly thanks so much everyone for the help.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.