Jump to content

vmicchia

Members
  • Posts

    78
  • Joined

  • Last visited

    Never

About vmicchia

  • Birthday 06/16/1986

Contact Methods

  • AIM
    marauder+II+mod
  • Website URL
    http://www.vmmdesigns.com

Profile Information

  • Gender
    Male
  • Location
    Lafayette, Indiana

vmicchia's Achievements

Member

Member (2/5)

0

Reputation

  1. As a note what this does is to take Comman seperated values from a text area in the format: a,b c,d d,e e,f And then put them into the hidden seperate text boxes.
  2. Hey there. I made this code in php. It now turns out that it has to be in JSP to work with my site. I'm trying to learn JSP but i'm really a beginner. Some help putting my php into JSP would be of great help. session_start(); /* /////////////////////////// Change Log //////////////////////// * 11/09/2011 - File Created */ //get data from user submission $str = $_POST['order']; //remove extra whitespce to avoid unfilled array nodes $str = trim($str); //Explode the array based on , and \n delemieters $array = explodeX(Array(",","\n"), $str); echo '<pre>'; print_r($array); echo '</pre>'; for($v=0;$v<=count($array);$v+=2){ if($array[$v] == "" || $array[$v] == " "){ header("Location:index.php"); } } for($t=1;$t<=count($array);$t+=2){ if(!is_numeric($array[$t])){ header("Location:index.php"); } } // form that will be automatically submitted without the user seeing echo '<form action="index.jsp?path=quickpadsummary" name="quickform" method="POST" onSubmit="loading(); return true;">'; echo '<input type="hidden" name="qpitems" value="<%=forminputs%>">'; echo '<input type="hidden" name="newsearch" value="true">'; echo '<input type="hidden" name="path" value="quickpadsummary">'; $f = 0; $l = 1; //echo theform inputs based on the array that was created for($p=0;$p<=(count($array)/2);$p++){ echo '<input type="hidden" name="pnum'.$p.'" value="'.$array[$f].'">'; echo '<input type="hidden" name="qty'.$p.'" value="'.$array[$l].'">'; $f+=2; $l+=2; } echo '</form>'; //java script to submit the form as soon as it loads. echo '<script type="text/javascript">'; echo 'function myfunc () {'; echo 'var frm = document.getElementById("quickform");'; echo 'frm.submit();'; echo '}'; echo 'window.onload = myfunc;'; echo '</script>'; function explodeX($delimiters,$string) { $return_array = Array($string); // The array to return $d_count = 0; while (isset($delimiters[$d_count])) // Loop to loop through all delimiters { $new_return_array = Array(); foreach($return_array as $el_to_split) // Explode all returned elements by the next delimiter { $put_in_new_return_array = explode($delimiters[$d_count],$el_to_split); foreach($put_in_new_return_array as $substr) // Put all the exploded elements in array to return { $new_return_array[] = $substr; } } $return_array = $new_return_array; // Replace the previous return array by the next version $d_count++; } return $return_array; // Return the exploded elements }
  3. Don't worry about it. It turned out to be the php.ini file. They were widlyy different despite never having been touched.
  4. Another odd thing I discovered. is that even if I copy the working site to a new domain it has the same issue even though it's the exact same site.
  5. Also here's what the array output is supposed to look like with 2 products.(this is what the site that works, and has the same code, shows.):
  6. Ok I apologize. I have taken out the array values but that didn't help. Here is a cut down version of the code for just one product, because the rest is just repeating for different products and has the same issue: if($_POST['product'] == 'cushion'){ // Set up all the needed variables if(empty($_POST['sku'])){ $_SESSION['orderError'] = 'There was an error please try again'; header($prevpage); }else{ $sku = $_POST['sku']; } if (!isset($_SESSION['cushIdentifier'])){ $_SESSION['cushIdentifier'] = 1; } if(!isset($_SESSION['cushArray'])){ $_SESSION['cushArray'] = array(); } if(empty($_POST['cushionName'])){ $_SESSION['orderError'] = 'No cushion selected.'; header($prevpage); }else{ $cushion = $_POST['cushionName']; } if(empty($_POST['fabricSelect'])){ $fabric = 'none'; }else{ $fabric = $_POST['fabricSelect']; } if(empty($_POST['fill'])){ $_SESSION['orderError'] = 'No Fill Selected'; header($prevpage); }else{ $fill = $_POST['fill']; } if(empty($_POST['buttonSelect'])){ $button = 'none'; }else{ $button = $_POST['buttonSelect']; } if(empty($_POST['contWelt'])){ $contWelt = 'none'; }else{ $contWelt = $_POST['contwelt']; } if(empty($_POST['weltFabricSelect'])){ $contWeltFab = 'none'; }else{ $contWeltFab = $_POST['weltFabricSelect']; } if(empty($_POST['zipper'])){ $zip = 'none'; }else{ $zip = $_POST['zipper']; } //echo $_POST['quant']; if(empty($_POST['quant']) || $_POST['quant'] == '0'){ $_SESSION['orderError'] = 'Please select the number of cushions you would like to order.'; header('Location:'.$prevpage); }else{ $quantity = $_POST['quant']; } if(empty($_POST['weltSize'])){ $weltSize = 'standard'; }else{ $weltSize = $_POST['WeltSize']; } if(empty($_POST['edge'])){ $edge = 'standard'; }else{ $edge = $_POST['edge']; } if(empty($_POST['cap'])){ $cap = 'none'; }else{ $cap = $_POST['cap']; } $hinged = $_POST['hinged']; $straps = $_POST['straps']; $type = $_POST['type']; $ties = $_POST['ties']; if(empty($_POST['BackHeight'])){ $bh = 'N/A'; }else{ $bh = $_POST['BackHeight']; } if(empty($_POST['BackWidth'])){ $bw = 'N/A'; }else{ $bw = $_POST['BackWidth']; } if(empty($_POST['BackThick'])){ $bt = 'N/A'; }else{ $bt = $_POST['BackThick']; } if(empty($_POST['SeatDepth'])){ $sd = 'N/A'; }else{ $sd = $_POST['SeatDepth']; } if(empty($_POST['SeatWidth'])){ $sw = 'N/A'; }else{ $sw = $_POST['SeatWidth']; } if(empty($_POST['SeatThick'])){ $st = 'N/A'; }else{ $st = $_POST['SeatThick']; } if(empty($_POST['weltTapeSelect'])){ $wt = 'N/A'; }else{ $wt = $_POST['weltTapeSelect']; } if(empty($_POST['price']) || $_POST['price'] == '0.00'){ $_SESSION['orderError'] = 'There was an error please try again'; header($prevpage); }else{ $price = $_POST['price']; } //echo $quantity.'<br />'; //echo $price.'<br />'; //echo $fabricPrice.'<br />'; //echo ($quantity * $fabricPrice).'<br />'; $total = ($quantity * $price) + ($quantity * $fabricPrice); //echo $total; //////////////////////////////////////////////////////// ///////SET THE ARRAY/////////////////////////////////// $cushArray = array( Cushion=> $cushion, Fabric=> $fabric, FabricPrice=> $fabricPrice, Fill=> $fill, Button=> $button, ContWelt=> $contWelt, ContWeltFabric=> $contWeltFab, Zipper=> $zip, Quantity=> $quantity, WeltSize=> $weltsize, SKU=> $sku, Edge=> $edge, Cap=> $cap, Hector=> $_POST['hector'], Stitch=> $_POST['stitch'], TopStitch=> $_POST['topstitch'], Ties=> $_POST['ties'], Measure=> $_POST['measurements'], Straps=> $straps, Hinged=> $hinged, Type=> $type, Price=> $price, Total=> $total, BackHeight=> $bh, BackWidth=> $bw, BackThick=> $bt, SeatDepth=> $sd, SeatWidth=> $sw, SeatThick=> $st, WeltTape=> $wt, ); //give the array an number and save to the session. $_SESSION['cushArray'][$_SESSION['cushIdentifier']] = $cushArray; $_SESSION['cushIdentifier']++; } Once again the problem is when I get 2 products into the array it gets messed up.(same as in above post)
  7. I have a file that creates sessions and adds to them for a shopping cart. On one site it works fine. On a second it seems to have issues when adding 2 of the same category of product. I have attached the file. when I echo the sessions with one product I get this: Array ( [total] => 1 [cushIdentifier] => 1 [cushArray] => Array ( [0] => Array ( [Cushion] => Boxed Chair Cushion [Fabric] => F-001H [FabricPrice] => 0 [Fill] => Layered Polyfiber [button] => 2 [ContWelt] => none [ContWeltFabric] => none [Zipper] => N [Quantity] => 1 [WeltSize] => [sKU] => JBBC2244 [Edge] => Boxed Edge [Cap] => N [Hector] => N [stitch] => [TopStitch] => N [Ties] => Y [Measure] => 136 [straps] => N [Hinged] => Y [Type] => [Price] => 111.39 [Total] => 111.39 [backHeight] => N/A [backWidth] => N/A [backThick] => N/A [seatDepth] => N/A [seatWidth] => N/A [seatThick] => N/A [WeltTape] => N/A ) ) ) But when I add a second it does this: ( [total] => 6 [cushIdentifier] => 2 [cushArray] => Array ( [0] => Boxed Chair Cushion [1] => F-009H [2] => 0 [3] => Layered Polyfiber [4] => 2 [5] => none [6] => none [7] => N [8] => 1 [9] => [10] => JBBC2244 [11] => Boxed Edge [12] => N [13] => N [14] => [15] => N [16] => Y [17] => 136 [18] => N [19] => Y [20] => [21] => 111.39 [22] => 111.39 [23] => N/A [24] => N/A [25] => N/A [26] => N/A [27] => N/A [28] => N/A [29] => N/A [30] => Array ( [Cushion] => Boxed Chair Cushion [Fabric] => F-009H [FabricPrice] => 0 [Fill] => Layered Polyfiber [button] => 2 [ContWelt] => none [ContWeltFabric] => none [Zipper] => N [Quantity] => 1 [WeltSize] => [sKU] => JBBC2244 [Edge] => Boxed Edge [Cap] => N [Hector] => N [stitch] => [TopStitch] => N [Ties] => Y [Measure] => 136 [straps] => N [Hinged] => Y [Type] => [Price] => 111.39 [Total] => 111.39 [backHeight] => N/A [backWidth] => N/A [backThick] => N/A [seatDepth] => N/A [seatWidth] => N/A [seatThick] => N/A [WeltTape] => N/A [1] => Array ( [Cushion] => Boxed Chair Cushion [Fabric] => F-009H [FabricPrice] => 0 [Fill] => Layered Polyfiber [button] => 2 [ContWelt] => none [ContWeltFabric] => none [Zipper] => N [Quantity] => 1 [WeltSize] => [sKU] => JBBC2244 [Edge] => Boxed Edge [Cap] => N [Hector] => N [stitch] => [TopStitch] => N [Ties] => Y [Measure] => 136 [straps] => N [Hinged] => Y [Type] => [Price] => 111.39 [Total] => 111.39 [backHeight] => N/A [backWidth] => N/A [backThick] => N/A [seatDepth] => N/A [seatWidth] => N/A [seatThick] => N/A [WeltTape] => N/A [1] => ) ) ) ) [attachment deleted by admin]
  8. I have a couple of loops that are supposed to 1) list all the values of one table as check boxes then 2)compare them to the values of another table. If they match that checkbox is supposed to be pre-checked. I have some code but it is not working just right yet and I was hoping someone could help me. <?php include("../../../cart/includes/openDbConn.php"); $sql = "SELECT Name FROM FabricType"; $dogettype = 'SELECT Type FROM FabricsTypes WHERE SKU = "'.$sku.'";'; $result = mysql_query($sql); while($results = mysql_fetch_array($result)) { if( $i % 3 == 0 ) { echo '</tr><tr>'; } $result2 = mysql_query($dogettype); while($results2 = mysql_fetch_array($result2)) { if(trim($results2['Type']) == trim($results['Name'])) { $ischecked = 'checked="checked"'; $value = 1; } else { $ischecked = ''; $value = 0; } } $i++; $tn = trim(ucfirst($results["Name"])); echo '<td> <label> <input type="checkbox" name="typeGroup1[]" '.$ischecked.' value="'.$results['Name'].'"> '.$tn.' </label> </td>'; } ?> With this code it echoes the check boxes correctly but only checks it if it is the last value in $results2. If I move the second while loop like so: <?php include("../../../cart/includes/openDbConn.php"); $sql = "SELECT Name FROM FabricType"; $dogettype = 'SELECT Type FROM FabricsTypes WHERE SKU = "'.$sku.'";'; $result = mysql_query($sql); while($results = mysql_fetch_array($result)) { if( $i % 3 == 0 ) { echo '</tr><tr>'; } $result2 = mysql_query($dogettype); while($results2 = mysql_fetch_array($result2)) { if(trim($results2['Type']) == trim($results['Name'])) { $ischecked = 'checked="checked"'; $value = 1; } else { $ischecked = ''; $value = 0; } $i++; $tn = trim(ucfirst($results["Name"])); echo '<td> <label> <input type="checkbox" name="typeGroup1[]" '.$ischecked.' value="'.$results['Name'].'"> '.$tn.' </label> </td>'; } } ?> It only echoes out the first results of $results for however many values there are in $results2. Thanks for any help.
  9. Check the header(); in whatever page redirects here. When I get this error it's usually because i forgot to write it as header('Location:example.php');
  10. Ok Maybe not solved. When $results2['Type']) has more than one value it will only check the last value in the array. The code I have now looks like this:
  11. Ok got it fixed I had to trim the results for comparison for some reason. Also can a mod mark as solved the button seems to be gone. Thanks. Also, thank you dawsba for your help.
  12. OK I tried that. It echoes out the check boxes correctly. But it does not check any boxes. In the case I am looking it it would only be one check box but it is possible for more to be checked.
  13. Ok so I have a few check box fields that are dynamically populated from a database. What I need to do is check the box if it is a selected value(this is an edit form for a product) so here's what I have but it is not working. <?php include("../../../cart/includes/openDbConn.php"); $sql = "SELECT Name FROM FabricType"; $result = mysql_query($sql); $gettype = 'SELECT Type FROM FabricsTypes WHERE SKU = "'.$sku.'";'; $dogettype = mysql_query($gettype); $vtype = mysql_fetch_assoc($dogettype); $count = count($vtype); $i = 0; while($row = mysql_fetch_array($result)){ if( $i % 3 == 0 ) { echo '</tr><tr>'; } while($vtype = mysql_fetch_assoc($dogettype)){ if($vtyp['Type'] == $row['Name']){ echo '<td><label><input type="checkbox" name="typeGroup1[]" checked="checked" value="'.trim($row["Name"]).'">'.trim(ucfirst($row["Name"])).'</label</td>'; }else{ echo '<td><label><input type="checkbox" name="typeGroup1[]" value="'.trim($row["Name"]).'">'.trim(ucfirst($row["Name"])).'</label</td>'; } } $i++; } ?> When I do this it echoes nothing out.
  14. Ok so what I have is a small code to enable a submit button when a selection is made in both radio button groups. But it's only validating for one of the groups. Here's the code: <script> function fCheck() { document.orderCushionForm.addToCart.disabled =(document.orderCushionForm.fabricSelect.checked <?php if($assoc['Buttons'] == 'Y'){echo '&& document.orderCushionForm.buttonSelect.checked';} ?>); } </script> It's run in each of the radio button groups with this: onclick=javascript:fCheck(); Also what would be the javascript code to disable the submit button beforehand so if a user had java disabled the button wouldn't be disabled?
  15. They are product tables for different types of products.
×
×
  • 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.