Jump to content

djones

Members
  • Posts

    74
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://

Profile Information

  • Gender
    Not Telling
  • Location
    Winston-Salem, NC

djones's Achievements

Member

Member (2/5)

0

Reputation

  1. I'm allowing the user to turn on SSL for the checkout page. I am checking if the file is writable via PHP, if it is I want PHP to add these lines, if it's not I am telling the user they need to add these lines manually.
  2. I need to add these lines to my .htaccess file via PHP RewriteCond %{REQUEST_URI} checkout RewriteRule ^(.*)$ https://myurl.com/checkout/$1 [R,L] RIGHT after this line: RewriteBase / AND before this line: RewriteCond %{REQUEST_FILENAME} !-f This is how the current file looks w/o the new line addition: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ index.php [L,QSA] It needs to look like this when the new lines are added(extra line breaks not necessary): RewriteBase / RewriteCond %{REQUEST_URI} checkout RewriteRule ^(.*)$ https://myurl.com/checkout/$1 [R,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ index.php [L,QSA] The line numbers may not match up, so I cannot use the line number.
  3. Wow, I'm made that real hard for myself. That's it. Thanks.
  4. I forgot the IGNORE in the INSERTs above. They all include that...
  5. In Oracle (*ducks*) I can do this. I was hoping for a way in MySQL. So is this not possible? I can work around this, but this would save me several lines of PHP code.
  6. I'm trying to insert unique data based on 2 fields. The product_id and the value_id combined should be unique. I'm not sure how to do this. I have: ID(primary key) -- not shown below PRODUCT_ID(unique key) VALUE_ID(unique key) VARIATION_ID I need product_id and value_id to be unique together. When I insert this data it only insert one row and I'm assuming it's because It's just looking at each unique fields by itself thus stopping at the next '37' insert. For example 37 and 11 should not insert twice, 37 and 3 ...etc INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '11', '4') INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '3', '2') INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '10', '4') INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '3', '2') INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '9', '4') INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '5', '2') INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '11', '4') INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '5', '2') INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '10', '4') INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '5', '2') INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '9', '4')
  7. A friend was able to help. I'm posting it here for others to see. // Put each variation set into an array // i.e $set[0] is your Sizes, $set[1] is your Colors /* Sizes array(4) { [0]=> string(2) "SM" [1]=> string(3) "MED" [2]=> string(2) "LG" [3]=> string(3) "XXL" } Colors array(3) { [0]=> string(4) "Blue" [1]=> string(5) "Green" [2]=> string(3) "Red" } */ $options = array(); $current_index_path = array(); $variations = -1; function variation_matrix($variations, $current_index_path, &$options, &$set) { $variations++; if ( $variations == count($set) - 1 ) { //you are at the last group for ( $i = 0; $i < count($set[$variations]); $i++ ) { $option_string = ""; for ( $j = 0; $j < count($current_index_path); $j++) { $option_string .= $set[$j][$current_index_path[$j]]. " : "; } $option_string .= $set[$variations][$i]; $options[] = $option_string; } } else { for ( $i = 0; $i < count($set[$variations]); $i++ ) { $cip_copy = $current_index_path; $cip_copy[] = $i; //append index from this variation variation_matrix($variations, $cip_copy, &$options, &$set); //dig deeper } } } variation_matrix($variations, $current_index_path, &$options, &$set); /* Output array(12) { [0]=> string(9) "SM : Blue" [1]=> string(10) "SM : Green" [2]=> string( "SM : Red" [3]=> string(10) "MED : Blue" [4]=> string(11) "MED : Green" [5]=> string(9) "MED : Red" [6]=> string(9) "LG : Blue" [7]=> string(10) "LG : Green" [8]=> string( "LG : Red" [9]=> string(10) "XXL : Blue" [10]=> string(11) "XXL : Green" [11]=> string(9) "XXL : Red" } */
  8. I'm struggling with how to dynamically loop through a product's list of options. Let's day I have the variations, Size(variation_id = 2) and Color(variation_id = 4) assigned to product A. Which produces these arrays: // Sizes array(4) { [0]=> string(2) "SM" [1]=> string(3) "MED" [2]=> string(2) "LG" [3]=> string(3) "XXL" } // Colors array(3) { [0]=> string(4) "Blue" [1]=> string(5) "Green" [2]=> string(3) "Red" } I know I can hard code the loop, but that will not work if I add another variation. How can I build the loop to work with any amount of variations? // Get the variations from the product_id A // $sql = "SELECT variation_id FROM product_variations WHERE product_id = 'A' / ... // I can query for the variations and loop through to get the variation values // ... // $set1 is the Sizes array from mysql query // $set2 is the Colors array from mysql query $count1 = count($set1); $count2 = count($set2); for ($a=0; $a < $count1; $a++){ for ($b=0; $b < $count2; $b++){ $options = $set1[$a].' : '.$set2[$b]; echo $options.'<br />'; } } // Output /* SM : Blue SM : Green SM : Red MED : Blue MED : Green MED : Red LG : Blue LG : Green LG : Red XXL : Blue XXL : Green XXL : Red */
  9. Cannot get my brain around what strtotime it looking for. I need to echo the same day for each month for the next 12 months. This is not working. for($i=0; $i<=12; $i++){ $date = date("Y-m-d", strtotime('17 +'.$i.' months')); echo $date.'<br />'; }
  10. I've read that article before and cannot find a way to create a dynamic menu from it. This part of the article where it shows the concat()... SELECT CONCAT( REPEAT( ' ', (COUNT(parent.name) - 1) ), node.name) AS name FROM nested_category AS node, nested_category AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt GROUP BY node.name ORDER BY node.lft; ... illustrates the idea but to create a valid <ul> list is different. You have to nest the tags correctly, and I cannot figure that part out.
  11. This works perfect for me, but I have another row with a page sort id. How do I sort the array with the page sort id? $page_sort_id = $row['page_sort_id'];
  12. I got it. I needed to change $content to $page_content.
  13. I can't seem to get my mind on this correctly. I need $page_content to go through each function, but It seems to either replace itself or duplicate itself. $filter is an array of function names $count = count($filter); if($count > 0){ foreach($filter as &$func){ $page_content = $func($content); // where the function returns the content. see sample functions below // $page_content .= $func($content); // not working either } } function replace_text($content){ $content = str_ireplace('test', 'WORKING', $content); return $content; } function replace_text_again($content){ $content = str_ireplace('page', 'THIS AN EXAMPLE', $content); return $content; } echo $page_content;
  14. I got lucky and tried to use the time offset from each timezone in seconds then use DATE_ADD/DATE_SUB based on the integer and corrected the time in the SQL statement to relfect the user's timezone. And it worked. Shew.... timezones area a headache. Went ok up until this point.
×
×
  • 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.