Jump to content

ginerjm

Members
  • Content Count

    4,770
  • Joined

  • Last visited

  • Days Won

    63

Everything posted by ginerjm

  1. So - however you accept a request from any person on your site to "see" a profile page - you need to simply check if they are signed in. If that means they have to have a certain $_SESSION element set, then all you do is call isset() for that item, no? What is the question about session_start all about? Obviously every script you execute should begin like this: <?php ... ... session_start();
  2. I don't understand any of this discussion. But the worst part of that lack is that I don't see any usage of "session_start()" in any of the many code samples. So my question is "What is the real problem"? Perhaps you could just explain what you are trying to accomplish?
  3. Judging by how well you write English, I'd be worried about your coding skills.....
  4. I don't often code like your example, I use the functions/methods rather than properties.
  5. Yes - that gets you days without the + sign. My last change was to show the months and leftover days, if you wanted it. $dt1 = '2009-10-11'; $dt2 = '2009-10-13'; echo "Using dates of $dt1 & $dt2 :<br>"; $interval = GetInterval($dt1, $dt2); $test = $interval->format('%m'); if ($test > 0) echo 'Interval is: '.$interval->format('%m months %d days'); else echo 'Interval is: '.$interval->format('%d days'); echo '<br><br>'; // test 2 $dt1 = '2009-08-14'; $dt2 = '2009-10-13'; echo "Using dates of $dt1 & $dt2 :<br>"; $interval = GetInterval($dt1, $dt2); $test = $interval->format('%m'); if ($test > 0) echo 'Interval is: '.$interval->format('%m months %d days'); else echo 'Interval is: '.$interval->format('%d days'); echo '<br><br>'; // test 3 $dt1 = '2009-07-11'; $dt2 = '2009-09-25'; echo "Using dates of $dt1 & $dt2 :<br>"; $interval = GetInterval($dt1, $dt2); $test = $interval->format('%m'); if ($test > 0) echo 'Interval is: '.$interval->format('%m months %d days'); else echo 'Interval is: '.$interval->format('%d days'); echo '<br><br>'; exit(); //****************************************** function GetInterval($dt1, $dt2) { $datetime1 = date_create($dt1); $datetime2 = date_create($dt2); $interval = date_diff($datetime1, $datetime2); return $interval; } Here is some code for you to try out.
  6. As for showing it in months - The manual does show you how but it is not immediately clear. After dropping the R, change the a to d
  7. Feeling magnanimous today, and having struggled to get to the correct source in the manual I"ll give you this one. Drop The R. As for showing it in months - the format options only show whole numbers so if you have a gap of less than a month you will show 0 when formatting it. And if it is more than a month you will get a value of "months" but not the full value of months & days without doing some work on figuring out how many days were in the months that did transpire.
  8. #$num = mysqli_num_rows($sql); #echo $num; Your two comments "fail"? Not sure how that can happen. Try echoing out your query before you execute it. Maybe just once (followed by an exit() ) to see if it is being built correctly.
  9. dBase??? I remember when that first came out. And people are still using it? Wow!
  10. How is this button going to work? What is it calling? How is the current row of data being passed to whatever script is going to do the delete? I suggest a form around each row and a proper Submit button (<input type='submit'>) that will do what you need. Using the <button> tag is just not that useful even though people love to use it. I don't get it.
  11. What do you mean by "have same variables but different data"? You do realize that one variable will replace any previously defined variable by the same name so having multiple uses of a single var name is not going to work?
  12. OK - you have 2 tables - Items and Bids so far. You are saying that you want to get some data items out of the query results and insert them into 2 other tables. Is that correct? Why not use your loop to create two arrays of the data items you want to add to each table. That is, a separate array for each of the 2 new tables. Then run an insert query on each one to insert those items, using the 'value arrays' to insert multiple rows in one query execution. Does that sound like a plan? BTW - in the query you posted - if close is a date or datetime or time field (by def.) you don't need quotes on the value since it is numeric. Just be sure it is in the proper format. And the same for the outbid value. Obviously you will need to add a while loop around that fetch line you have above. As for the group by, if has no use here since I believe all you are doing is collecting the joined sets of data in order to create your new input values for the other tables. BTW #2 - if you already have these data items in your database, why do you need to copy them to new tables?
  13. A rule of PHP is that php vars do not get interpreted if wrapped in single quotes. Leave them off in this case or use double quotes.
  14. So - why did you stop doing what I asked you to do?
  15. Since you can't seem to understand what I am asking to see, I'll stop now. Good luck.
  16. I don't see the line you commented out. I ASKED you to add a comment to SHOW where the problem line was. AND if you commented out the error line, OF COURSE the script will run. What's the point of that?
  17. BTW - another fantastic style of coding is to use the TAB key a lot!!! Makes is so much easier to read. I prefer to place my braces on separate lines rather than at the end of a line (where they can be missed!) so this is how I write all of my code: // Getting the current user role $curr_user = wp_get_current_user(); $curr_user_data = get_userdata($current_user->ID); // Wholesale Suite Roles if (isset($current_user) && class_exists('WWP_Wholesale_Roles')) { $wwp_wholesale_roles = WWP_Wholesale_Roles::getInstance(); $wwp_wholesale_role = $wwp_wholesale_roles->getUserWholesaleRole(); // Loop through the user role and shipping method pair foreach( $role_shipping_method_arr as $role => $shipping_methods_to_hide ) { // Check if defined role exist in current user role or not if( in_array( $role, $current_user->roles)) { // Loop through all the shipping rates foreach( $shipping_rates as $shipping_method_key => $shipping_method ) { $shipping_id = $shipping_method->get_id(); // Unset the shipping method if found if( in_array( $shipping_id, $shipping_methods_to_hide) ) { unset($shipping_rates[$shipping_method_key]); } } } } } return $shipping_rates; } ); Doesn't that make it easier to see where you are in that mess? Of course having this whole thing embedded inside the call to "array_filter" doesn't make it any easier. Can't you just define the function outside that WP call and reference it by name? I don't use WP so I may be wrong.
  18. Ok - I know for a fact that the array I gave you is perfect so your new error is of your doing. Which line is it? Maybe add a comment before that line being pointed out by the message line number?
  19. As I stated in the other forum where you posted you really need to see how a php script should/could be properly written. Here is an example of how your script could/should look. I don't know all of your planned actions with this but at least this shows you the proper format of a well-written script. <?php session_start(); // Check if we have inputs if(isset($_POST['voice_sku']) && isset($_POST['voice_name'])) { // Process the inputs here. $_SESSION['voice_sku'] = $_POST['voice_sku']; $_SESSION['voice_name'] = $_POST['voice_name']; } else // what to do if we DON'T have inputs? { } //***************************** // Done processing the inputs so time to do the output // Now build the output table $code=<<<heredocs <table width="100%" cellpadding="6" cellspacing="0"> <thead> <tr> <th>Voice Sku</th> <th>Voice Name</th> <th>Remove</th> </tr> </thead> <tbody> <!-- WHAT IS THIS ROW HERE FOR??? --> <!-- AND WHY A COLSPAN OF 5 WHEN YOU ONLY HAVE 3 HEADINGS???? --> <tr> <td colspan="5"> <span style="float:right;text-align: right;"> </span> </td> </tr> <!-- WHAT IS THIS ROW HERE FOR??? --> <!-- AND WHY A COLSPAN OF 5 WHEN YOU ONLY HAVE 3 HEADINGS???? --> <tr> <td colspan="5"> <a href="index.php" class="button">Add More Items</a> <button type="submit">Update</button> </td> </tr> <!-- Put Input Values HERE --> <form action='' method='POST'> <tr> <td> <input type='text' name='voice_sku' value="{$_SESSION['voice_sku']}"> </td> <td> <input type='text' name='voice_name' value="{$_SESSION['voice_name']}"> </td> <td> <input type='submit' name='btn' value='Remove'> </td> </tr> </form> </tbody> </table> heredocs; echo $code; exit(); // are we done? 1 - start the session 2 - check for inputs 2a - handle missing inputs? 3 - process the inputs 4 - build the output No mixing of html code inside the php code.
  20. And that is proof that we have built your array properly. That is all. Now you know what your look-up table looks like and can move forward with your app.
  21. Ok - I've had a long day and may have been mis-directing you with some of this. So - I built a script to test it all out and here it is. <?php $role_shipping_method_arr = array ( 'retail' => array ( 'customer' => array ( 'Silvia Premium Standard Shipping (Tracking Service)', 'Silvia Union Standard Shipping (Tracking Service)' ), 'customer_pst_exempt' => array ( 'Silvia Premium Standard Shipping (Tracking Service)', 'Silvia Union Standard Shipping (Tracking Service)' ), 'customer_tax_exempt' => array ( 'Silvia Premium Standard Shipping (Tracking Service)', 'Silvia Union Standard Shipping (Tracking Service)' ) ), 'wholesale' => array ( 'wholesale_customer' => array ( 'Silvia Premium Standard Shipping (Tracking Service)', 'Silvia Union Standard Shipping (Tracking Service)' ), 'wholesale_pst_exempt' => array ( 'Silvia Premium Standard Shipping (Tracking Service)', 'Silvia Union Standard Shipping (Tracking Service)' ), 'wholesale_tax_exempt' => array ( 'Silvia Premium Standard Shipping (Tracking Service)', 'Silvia Union Standard Shipping (Tracking Service)' ), 'ws_silvia_silver' => array ( 'Silvia Premium Standard Shipping (Tracking Service)', 'Silvia Union Standard Shipping (Tracking Service)' ), 'ws_silvia_silver_pst_exempt' => array ( 'Silvia Premium Standard Shipping (Tracking Service)', 'Silvia Union Standard Shipping (Tracking Service)' ), 'ws_silvia_silver_tax_exempt' => array ( 'Silvia Premium Standard Shipping (Tracking Service)', 'Silvia Union Standard Shipping (Tracking Service)' ), 'ws_silvia_gold' => array ( 'Silvia Premium Standard Shipping (Tracking Service)', 'Silvia Union Standard Shipping (Tracking Service)' ), 'ws_silvia_gold_pst_exempt' => array ( 'Silvia Premium Standard Shipping (Tracking Service)', 'Silvia Union Standard Shipping (Tracking Service)' ), 'ws_silvia_gold_tax_exempt' => array ( 'Silvia Premium Standard Shipping (Tracking Service)', 'Silvia Union Standard Shipping (Tracking Service)' ) ) ); echo "Array is<pre>",print_r($role_shipping_method_arr,true),'</pre>'; exit; Upload this EXACT script and run it and see what you get.
  22. Well, you're missing some quotes and some equal signs and the very last ) , but you'll get the hang of it.
  23. Not examples per se. Just the ideas I suggested to use the existing arrays that are available to you instead of making needless variables only to insert them into an array over again. For ex. array_push($page_arr['pages'], $row); This one line can replace all that code you are doing in your loop. And using fetchall instead of a fetch would replace the whole loop.
×
×
  • 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.