Jump to content

cyberRobot

Moderators
  • Posts

    3,145
  • Joined

  • Last visited

  • Days Won

    37

Everything posted by cyberRobot

  1. What do you use to create the PDF? If the original document is created in something like Microsoft Word, you can make sure each page has an identifier which is marked as a heading under Styles. Then you can use that style to automatically create Bookmarks in the PDF. More information can be found here: https://acrobatusers.com/tutorials/how-to-create-structured-bookmarks To automatically show the Bookmarks panel when the PDF is open, you can Click File > Properties... Click the Initial View tab Under Layout and Magnification, click the "Bookmarks Panel and Page" option under the Navigation tab drop down
  2. You could consider using page links: https://helpx.adobe.com/acrobat/kb/link-html-pdf-page-acrobat.html Note, however, that the solution isn't going to work in all browsers.
  3. Good catch. For some reason I though intval extracted the number from a string. @ludah - Are you trying to get 20 and 500 from "FBR-20" and "FBR-500"? If so, you could use explode() to break each string based on the hyphen. Yep, thanks for catching that ginerjm!
  4. Also note that you're overwriting the $array variable here: $array = $q = mysqli_query(... Basically, $array will contain whatever is assigned to $q. The script will probably work fine though since $array gets used before the value of $q is assigned to $array.
  5. Assuming that you are using PHP's array_map() function, the call needs to be made outside of the string. Try changing this $q = mysqli_query($dbc,"SELECT * FROM tree_tbl WHERE `id` IN (array_map('intval','$array'))"); To this $q = mysqli_query($dbc,"SELECT * FROM tree_tbl WHERE `id` IN (" . array_map('intval', $array) . ")");
  6. No problem; glad to help! For what it's worth, you could eliminate some duplication by calling wc_get_product_terms() in a loop: $taxonomyOfInterest = array( 'pa_car-make', 'pa_no-of-doors' ); $attributes = array(); foreach($taxonomyOfInterest as $currTaxonomy) { $attributes[$currTaxonomy] = array_shift( wc_get_product_terms( $post_id , $currTaxonomy, array( 'fields' => 'names' ) ) ); }
  7. Looking at your code a bit closer, you probably want to run the test within the loop. Maybe something like this: foreach ($attributes as $name => $value) { if(!empty($value)) { $product_attributes[$i] = array ( 'name' => htmlspecialchars( stripslashes( $name ) ), // set attribute name 'value' => $value, // set attribute value 'position' => 1, 'is_visible' => 1, 'is_variation' => 0, 'is_taxonomy' => 0, 'row' => $i ); $i++; } } That way one of your attributes can be empty and the loop will still execute.
  8. Sorry about the confusion, the $attributes array doesn't exist until after the following block of code: $attributes = array( 'pa_car-make' => array_shift( wc_get_product_terms( $post_id , 'pa_car-make', array( 'fields' => 'names' ) ) ), 'pa_no-of-doors' => array_shift( wc_get_product_terms( $post_id, 'pa_no-of-doors', array( 'fields' => 'names' ) ) ) ); So the if empty test needs to take place after the array is created. Assuming that you only want the foreach loop to execute if the "pa_car-make" value isn't empty, you could try something like this: if(!empty($attributes['pa_car-make'])) { $i = 0; // Loop through the attributes array foreach ($attributes as $name => $value) { $product_attributes[$i] = array ( 'name' => htmlspecialchars( stripslashes( $name ) ), // set attribute name 'value' => $value, // set attribute value 'position' => 1, 'is_visible' => 1, 'is_variation' => 0, 'is_taxonomy' => 0, 'row' => $i ); $i++; } }
  9. You could try something like this: if(empty($attributes['pa_car-make'])) {
  10. You need to move the following print_r() function outside of the foreach loop: <pre><?php print_r($product_attributes); ?></pre>
  11. First I would imagine that the "1008" found in the line below: $pa_no_of_doors_value = array_shift( wc_get_product_terms( 1008, 'pa_no-of-doors', array( 'fields' => 'names' ) ) ); ...is going to be the same as $post_id here: $pa_car_make_value = array_shift( wc_get_product_terms( $post_id, 'pa_car-make', array( 'fields' => 'names' ) ) ); Assuming that's correct, you'll want to use the variable instead of hard coding the number. As for the loop, what are you trying to loop through? A series of post IDs? Or does wc_get_product_terms() in the following code pass back multiple values that you need to process? $pa_no_of_doors_value = array_shift( wc_get_product_terms( 1008, 'pa_no-of-doors', array( 'fields' => 'names' ) ) ); $pa_car_make_value = array_shift( wc_get_product_terms( $post_id, 'pa_car-make', array( 'fields' => 'names' ) ) );
  12. So basically, you're looking to use the width and height in JavaScript...is that correct? If so, the values are already there when the browser window is re-sized. To make the values available to other parts of your JavaScript, you could pass them to a function. Here's a quick example: <script type="text/javascript" src="http://americanoldtimers.nl/js/jquery-1.4.2.min.js"></script> <script type="text/javascript"> jQuery(window).resize(function() { viewportwidth = window.innerWidth; viewportheight = window.innerHeight; displayWindowSize(viewportwidth, viewportheight); }); function displayWindowSize(width, height) { $('.results').html(width); $('.results2').html(height); } </script> <span class='results'>Width</span> <BR> <span class='results2'>Height</span> <P> <span class='results'>Width</span> <BR> <span class='results2'>Height</span> Note that you can find more information about JavaScript functions here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions
  13. What is the exact error message? Does it refer to the following line: $isTtex = $_GET['varname']; If so, you could change it to if(isset($_GET['varname'])) { $isTtex = $_GET['varname']; } However, I wonder if the undefined error refers to the code in your footer. Perhaps the code is imported in a different scope from the rest of the PHP code. If that's the case, $isTtex below will be undefined: <?php if (isset($isTtex)) : ?> To fix that, you could use <?php if (isset($_GET['varname'])) : ?>
  14. Do both code blocks work? If so, are you just wondering how to combine them? If so, have you tried something like: var suggestCallBack; // global var for autocomplete jsonp var keywordCount = 0; var alphabet = "abcdefghijklmnopqrstuvwxyz0123456789".split(""); $('body').on("click", '#submit', function() { $('#keywords').html(''); var search_input = $("#keyword").val(); var language = $("#edit-domain").val(); callAPI(search_input, language); _.each(alphabet, function(letter) { callAPI(search_input + ' ' + letter); callAPI(letter + ' ' + search_input); }); return false; });
  15. So are you trying to output content within the <span> tag? If so, you could use getElementsByClassName() to target the tag. More information can be found here: https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName You could then use innerHTML to add the content. More information can be found here: https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML Just keep in mind that getElementsByClassName() returns an array-like object. Here's an example of someone using the function and looping through the results: http://blog.cjgammon.com/getelementsbyclassname/
  16. You need to use the full variable name. Try changing this Hello <?php print stripslashes($_REQUEST['tytle']['firnam']['lasnam']); ?>. To this Hello <?php print stripslashes($_REQUEST['tytle'] . $_REQUEST['firnam'] . $_REQUEST['lasnam']); ?>. Also, I imagine that $_REQUEST['tytle'] should be $_REQUEST['title'].
  17. Basically, you would change your <option> tags to something like this <select name="bustype" class="dropforopt"> <option value="" disabled="disabled" selected="selected">Type of business...</option> <option value="Guest House">Guest House</option> <option value="Village Haul">Village Haul</option> <option value="Small Office">Small Office (up to 10 people)</option> <option value="Medium Office">Medium Office (up to 50 people)</option> <option value="Hair Salon">Hair Salon</option> </select> Then on the PHP side, you could run a test on the "bustype" variable using something like this <?php switch($_REQUEST['bustype']) { case 'Guest House': $to = 'guest.house@test.com'; break; case 'Village Haul': $to = 'village.haul@test.com'; break; case 'Small Office': $to = 'sm.office@test.com'; break; case 'Medium Office': $to = 'med.office@test.com'; break; case 'Hair Salon': $to = 'hair.salon@test.com'; break; } ?>
  18. You could just pass the business type. And then have PHP look up the corresponding email address(es).
  19. Side note: it's best to avoid using $_REQUEST. The variable is generated based on whatever is sent using GET, POST, COOKIES, etc. and is more susceptible to attacks. More information about $_REQUEST can be found here: http://php.net/manual/en/reserved.variables.request.php It better to using the variable which corresponds to how the information is being passed to PHP. If your form's method is set to POST, for example, you would be better off to us $_POST. More information can be found here: http://php.net/manual/en/reserved.variables.post.php
  20. The problem is that you are using double quotes inside of a double quoted attribute value. In the following <option> tag, "Guest House" is the only thing that gets passed. And "noreply@test.com" is ignored by the browser. <option value="Guest House""noreply@test.com">Guest House</option> The reason why the following works, is because the email address is before the first closing double quote. And "2" is ignored by the browser. <option value="noreply@test.com""2">Village Haul</option>
  21. The code works for me also... What version of PHP are you using? Also, is PHP set to show all errors and warnings? Note that you can add the following to the top of your script during the debugging process: <?php error_reporting(E_ALL); ini_set('display_errors', 1); ?>
  22. If you echo out $visitors before the if test that changes $result to NULL, you'll see that the value has been changed. <?php //... echo "<div>$visitors</div>"; //If the visitors don't fit in the gap of available seats. if($visitors>$gap){ $result = NULL; } //... ?> One way around this is to create a temporary variable which will be used in the loop. <?php //... function suggestSeats($seats,$visitors){ $visitorsToProcess = $visitors; foreach($seats as &$val){ //If available if($val['seatAvailable'] == '1'){ //If there's no gap, start making one now: if($gap<1){ $gap = 1; } $gap++; //IF THERE ARE STILL VISITORS TO PROCESS, MARK THE SUGGESTED SEAT if($visitorsToProcess > 0) { $val['seatAvailable'] = 'x'; $visitorsToProcess--; } } //IF THERE ARE NO MORE VISITORS, EXIT LOOP if($visitorsToProcess == 0) { break; } } echo "<div>Visitors before loop: $visitors</div>"; echo "<div>Visitors after loop: $visitorsToProcess</div>"; echo "<div>Gap: $gap</div>"; //If the visitors don't fit in the gap of available seats. if($visitors>$gap){ $result = NULL; } else{ $result = $seats; } return $result; } ...// ?>
  23. Just to clarify, do you want the script to output one result (Pending, Incomplete, etc.)? If so, I think in_array() and elseif should work fine. But I'm sure there are other ways. It depends on what you are trying to do and what you are doing with the rest of the code.
  24. Have you considered using elseif? More information can be found here: http://php.net/manual/en/control-structures.elseif.php If that doesn't work, it might help if you provide more information on what you're trying to accomplish.
  25. You could loop through $_POST['item_meta']. Here's a quick example: <?php //IF FORM WAS SUBMITTED if($_SERVER['REQUEST_METHOD'] == 'POST') { foreach($_POST['item_meta'] as $currIndex => $currValue) { print "<div>$currIndex = $currValue</div>"; } } ?> <form method="post"> <input type="text" name="item_meta[124]" /> <input type="text" name="item_meta[125]" /> <input type="text" name="item_meta[128]" /> <input type="text" name="item_meta[132]" /> <input type="submit" name="submit" value="Save" /> </form>
×
×
  • 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.