Jump to content

doc1355

Members
  • Posts

    54
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling
  • Location
    Earth, Trying to get to Mars

Recent Profile Visitors

748 profile views

doc1355's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

1

Community Answers

  1. The script is designed so that it can create hundreds of posts at a specific time. Each post is based on a specific criteria, specific custom taxonomy. I don't think WP can do this. Also the script updates the posts based on some other criteria at a certain time.
  2. Each post content is not dynamic. However the function creates many posts at the same time based on some criteria. Old posts will remain visible and accessible.
  3. It’s a Wordpress site. Functions will create custom posts.
  4. Correct. Is that good practice? Will I be able to secure the function? Only to be run by the cron on my server and admin only?
  5. I'm developing a website for specific EVENTS. Each EVENT lasts for three months and has fixed start date and end date, and they repeat each year: Event 1: Jan. 1st – Mar. 31st Event 2: Apr. 1st – Jun. 30th Event 3: Jul. 1st – Sep. 30th Event 4: Oct. 1st – Dec. 31st I have two functions FUNCTION 1: should run 3 days before start of the event. FUNCTION 2: should run 1 day before start of last month of the event. Functions should execute only that specific event and not other future or past events. Here how the functions should run for each Event: Event 1: Jan. 1st – Mar. 31st Function 1: on Dec 29 Function 2: last day of Feb Event 2: Apr. 1st – Jun. 30th Function 1: on Mar 29 Function 2: last day of May Event 3: Jul. 1st – Sep. 30th Function 1: on Jun 28th Function 2: Last day of Aug Event 4: Oct. 1st – Dec. 31st Function 1: on Sept 28th Function 2: last day of Nov What I'm doing right now is checking today's date and comparing it to the event date. If event start date is > today and event start date < 3 then run function one. My problem/questions: As of now, I have to remember to execute the functions manually on a specific date. How can I make this automated? Can I execute the function using server Cron job? Will that be a good practice? How would you approach in checking the event date to today? I feel there maybe better way of checking the date to run the function instead of what I'm doing. I hope my question is not vague and makes sense. Thank you.
  6. I have a php page tool.php that has a function named "create_event". I want to make a button in a different page (dashboard.php), that when I click on it, it runs the "create_event" function from tool.php and shows the output from the function on dashboard.php page. I'm totally new to ajax and jquery and not sure how to do this. I did google this but not much luck. My site is build with WordPress and this is part of custom plugin that I'm making. Thank you in advance.
  7. Correction the closing tag for the tbody and table should be outside the the last foreach loop. $output = '<table class="uk-table uk-table-striped uk-table-small"><tbody>'; foreach ( $cleaned_player_id as $c ) { $output .= '<tr><td>' . $c . '</td>'; foreach ( $match_array as $m ) { if ( $m[ 'p1' ] == $c ) { $output .= '<td>' . $m[ 'p2' ] . '<br>' . $m[ 's1p1' ] . '-' . $m[ 's1p2' ] . ', ' . $m[ 's2p1' ] . '-' . $m[ 's2p2' ] . ', ' . $m[ 's3p1' ] . '-' . $m[ 's3p2' ] . '</td>'; } elseif ( $m[ 'p2' ] == $c ) { $output .= '<td>' . $m[ 'p1' ] . '<br>' . $m[ 's1p2' ] . '-' . $m[ 's1p1' ] . ', ' . $m[ 's2p2' ] . '-' . $m[ 's2p1' ] . ', ' . $m[ 's3p2' ] . '-' . $m[ 's3p1' ] . '</td>'; } } $output .= '</tr>'; } $output .= '</tbody></table>';
  8. @Barand Thanks to your last suggestion, I was able to make the table the way I wanted. Here is what I did: I add all the players to an array. I created an array to collect all the players ID, and a separate array to collect all the data for each match: while ( $match_query->have_posts() ) { $match_query->the_post(); $match_id = get_the_ID(); // Get the ID of each Match post in this event. $related_user_1 = get_post_meta( $match_id, 'related_user_1' ); $related_user_2 = get_post_meta( $match_id, 'related_user_2' ); $set_1_player_1 = get_post_meta( $match_id, 'set_1_player_1' ); $set_1_player_2 = get_post_meta( $match_id, 'set_1_player_2' ); $set_2_player_1 = get_post_meta( $match_id, 'set_2_player_1' ); $set_2_player_2 = get_post_meta( $match_id, 'set_2_player_2' ); $set_3_player_1 = get_post_meta( $match_id, 'set_3_player_1' ); $set_3_player_2 = get_post_meta( $match_id, 'set_3_player_2' ); $all_players[] = $related_user_1[ 0 ][ ' ID' ]; $all_players[] = $related_user_2[ 0 ][ ' ID' ]; $match_array[] = array( 'p1' => $related_user_1[ 0 ][ ' ID' ], 'p2' => $related_user_2[ 0 ][ ' ID' ], 's1p1' => $set_1_player_1[ 0 ] ?? '', 's1p2' => $set_1_player_2[ 0 ] ?? '', 's2p1' => $set_2_player_1[ 0 ] ?? '', 's2p2' => $set_2_player_2[ 0 ] ?? '', 's3p1' => $set_3_player_1[ 0 ] ?? '', 's3p2' => $set_3_player_2[ 0 ] ?? '', ); } Then I removed the duplicate players from the player array: $cleaned_player_id = array_unique( $all_players ); Now here comes the table: First I enter the unique player from the cleaned list into the first column. Then I loop through match data with if statement and show the results accordingly. $output = '<table class="uk-table uk-table-striped uk-table-small"><tbody>'; foreach ( $cleaned_player_id as $c ) { $output .= '<tr><td>' . $c . '</td>'; foreach ( $match_array as $m ) { if ( $m[ 'p1' ] == $c ) { $output .= '<td>' . $m[ 'p2' ] . '<br>' . $m[ 's1p1' ] . '-' . $m[ 's1p2' ] . ', ' . $m[ 's2p1' ] . '-' . $m[ 's2p2' ] . ', ' . $m[ 's3p1' ] . '-' . $m[ 's3p2' ] . '</td>'; } elseif ( $m[ 'p2' ] == $c ) { $output .= '<td>' . $m[ 'p1' ] . '<br>' . $m[ 's1p2' ] . '-' . $m[ 's1p1' ] . ', ' . $m[ 's2p2' ] . '-' . $m[ 's2p1' ] . ', ' . $m[ 's3p2' ] . '-' . $m[ 's3p1' ] . '</td>'; } } $output .= '</tr></tbody></table>'; } Please let me know your thoughts?
  9. Ok, let's try one more time. I changed my array script to this: $match[] = array( 'p1' => $related_user_1[ 0 ][ 'ID' ], 'p2' => $related_user_2[ 0 ][ 'ID' ], 's1p1' => $set_1_player_1, 's1p2' => $set_1_player_2, 's2p1' => $set_2_player_1, 's2p2' => $set_2_player_2, 's3p1' => $set_3_player_1, 's3p2' => $set_3_player_2, ); This will give me the following var_export: array ( 0 => array ( 'p1' => 'Sam Bina', 'p2' => 'David Smith', 's1p1' => array ( ), 's1p2' => array ( ), 's2p1' => array ( ), 's2p2' => array ( ), 's3p1' => array ( ), 's3p2' => array ( ), ), 1 => array ( 'p1' => 'Sam Bina', 'p2' => 'Fred Thompson', 's1p1' => array ( ), 's1p2' => array ( ), 's2p1' => array ( ), 's2p2' => array ( ), 's3p1' => array ( ), 's3p2' => array ( ), ), 2 => array ( 'p1' => 'Fred Thompson', 'p2' => 'Frank Molino', 's1p1' => array ( ), 's1p2' => array ( ), 's2p1' => array ( ), 's2p2' => array ( ), 's3p1' => array ( ), 's3p2' => array ( ), ), 3 => array ( 'p1' => 'Frank Molino', 'p2' => 'David Smith', 's1p1' => array ( ), 's1p2' => array ( ), 's2p1' => array ( ), 's2p2' => array ( ), 's3p1' => array ( ), 's3p2' => array ( ), ), 4 => array ( 'p1' => 'Sam Bina', 'p2' => 'Fred Thompson', 's1p1' => array ( 0 => '6', ), 's1p2' => array ( 0 => '2', ), 's2p1' => array ( 0 => '3', ), 's2p2' => array ( 0 => '6', ), 's3p1' => array ( ), 's3p2' => array ( ), ), 5 => array ( 'p1' => 'Frank Molino', 'p2' => 'David Smith', 's1p1' => array ( 0 => '6', ), 's1p2' => array ( 0 => '1', ), 's2p1' => array ( 0 => '6', ), 's2p2' => array ( 0 => '2', ), 's3p1' => array ( ), 's3p2' => array ( ), ), 6 => array ( 'p1' => 'Fred Thompson', 'p2' => 'Frank Molino', 's1p1' => array ( 0 => '6', ), 's1p2' => array ( 0 => '2', ), 's2p1' => array ( 0 => '7', ), 's2p2' => array ( 0 => '5', ), 's3p1' => array ( ), 's3p2' => array ( ), ), 7 => array ( 'p1' => 'Fred Thompson', 'p2' => 'David Smith', 's1p1' => array ( 0 => '5', ), 's1p2' => array ( 0 => '7', ), 's2p1' => array ( 0 => '7', ), 's2p2' => array ( 0 => '5', ), 's3p1' => array ( 0 => '6', ), 's3p2' => array ( 0 => '3', ), ), 8 => array ( 'p1' => 'Fred Thompson', 'p2' => 'David Smith', 's1p1' => array ( 0 => '6', ), 's1p2' => array ( 0 => '2', ), 's2p1' => array ( 0 => '6', ), 's2p2' => array ( 0 => '1', ), 's3p1' => array ( ), 's3p2' => array ( ), ), 9 => array ( 'p1' => 'Sam Bina', 'p2' => 'Frank Molino', 's1p1' => array ( 0 => '1', ), 's1p2' => array ( 0 => '6', ), 's2p1' => array ( 0 => '2', ), 's2p2' => array ( 0 => '6', ), 's3p1' => array ( ), 's3p2' => array ( ), ), 10 => array ( 'p1' => 'Sam Bina', 'p2' => 'David Smith', 's1p1' => array ( 0 => '3', ), 's1p2' => array ( 0 => '6', ), 's2p1' => array ( 0 => '6', ), 's2p2' => array ( 0 => '3', ), 's3p1' => array ( 0 => '6', ), 's3p2' => array ( 0 => '2', ), ), 11 => array ( 'p1' => 'Sam Bina', 'p2' => 'Frank Molino', 's1p1' => array ( 0 => '6', ), 's1p2' => array ( 0 => '4', ), 's2p1' => array ( 0 => '6', ), 's2p2' => array ( 0 => '4', ), 's3p1' => array ( ), 's3p2' => array ( ), ), ) Can this be used to create the table?
  10. I created some dummy users, matches and results to make it easier to read the output. Here is the var_export for $pair_id. Please let me know if you need other information: array ( 0 => array ( 'Sam Bina' => array ( 'u2' => 'David Smith', 's1p1' => array ( ), 's1p2' => array ( ), 's2p1' => array ( ), 's2p2' => array ( ), 's3p1' => array ( ), 's3p2' => array ( ), ), ), 1 => array ( 'Sam Bina' => array ( 'u2' => 'Fred Thompson', 's1p1' => array ( ), 's1p2' => array ( ), 's2p1' => array ( ), 's2p2' => array ( ), 's3p1' => array ( ), 's3p2' => array ( ), ), ), 2 => array ( 'Fred Thompson' => array ( 'u2' => 'Frank Molino', 's1p1' => array ( ), 's1p2' => array ( ), 's2p1' => array ( ), 's2p2' => array ( ), 's3p1' => array ( ), 's3p2' => array ( ), ), ), 3 => array ( 'Frank Molino' => array ( 'u2' => 'David Smith', 's1p1' => array ( ), 's1p2' => array ( ), 's2p1' => array ( ), 's2p2' => array ( ), 's3p1' => array ( ), 's3p2' => array ( ), ), ), 4 => array ( 'Sam Bina' => array ( 'u2' => 'Fred Thompson', 's1p1' => array ( 0 => '6', ), 's1p2' => array ( 0 => '2', ), 's2p1' => array ( 0 => '3', ), 's2p2' => array ( 0 => '6', ), 's3p1' => array ( ), 's3p2' => array ( ), ), ), 5 => array ( 'Frank Molino' => array ( 'u2' => 'David Smith', 's1p1' => array ( 0 => '6', ), 's1p2' => array ( 0 => '1', ), 's2p1' => array ( 0 => '6', ), 's2p2' => array ( 0 => '2', ), 's3p1' => array ( ), 's3p2' => array ( ), ), ), 6 => array ( 'Fred Thompson' => array ( 'u2' => 'Frank Molino', 's1p1' => array ( 0 => '6', ), 's1p2' => array ( 0 => '2', ), 's2p1' => array ( 0 => '7', ), 's2p2' => array ( 0 => '5', ), 's3p1' => array ( ), 's3p2' => array ( ), ), ), 7 => array ( 'Fred Thompson' => array ( 'u2' => 'David Smith', 's1p1' => array ( 0 => '5', ), 's1p2' => array ( 0 => '7', ), 's2p1' => array ( 0 => '7', ), 's2p2' => array ( 0 => '5', ), 's3p1' => array ( 0 => '6', ), 's3p2' => array ( 0 => '3', ), ), ), 8 => array ( 'Fred Thompson' => array ( 'u2' => 'David Smith', 's1p1' => array ( 0 => '6', ), 's1p2' => array ( 0 => '2', ), 's2p1' => array ( 0 => '6', ), 's2p2' => array ( 0 => '1', ), 's3p1' => array ( ), 's3p2' => array ( ), ), ), 9 => array ( 'Sam Bina' => array ( 'u2' => 'Frank Molino', 's1p1' => array ( 0 => '1', ), 's1p2' => array ( 0 => '6', ), 's2p1' => array ( 0 => '2', ), 's2p2' => array ( 0 => '6', ), 's3p1' => array ( ), 's3p2' => array ( ), ), ), 10 => array ( 'Sam Bina' => array ( 'u2' => 'David Smith', 's1p1' => array ( 0 => '3', ), 's1p2' => array ( 0 => '6', ), 's2p1' => array ( 0 => '6', ), 's2p2' => array ( 0 => '3', ), 's3p1' => array ( 0 => '6', ), 's3p2' => array ( 0 => '2', ), ), ), 11 => array ( 'Sam Bina' => array ( 'u2' => 'Frank Molino', 's1p1' => array ( 0 => '6', ), 's1p2' => array ( 0 => '4', ), 's2p1' => array ( 0 => '6', ), 's2p2' => array ( 0 => '4', ), 's3p1' => array ( ), 's3p2' => array ( ), ), ), )
  11. You won't make it worse. Let me explain, The line get_post_meta( $match_id, 'related_user_1' ) captures the user array for player 1. ( we need to add [ 0 ][ 'ID' ] to get the ID) change 'related_user_1' and you will get other results from the match: related_user_2 will be player 2 set_1_player_1 is the value for first set, player 1. This is not an array. It is just the value itself. set_1_player_2 is the value for first set, player 2. This is not an array. It is just the value itself. and so on. All the above are running in a while() loop so that it captures all the results for the event. Each time this loop runs, it collects the data for one match, which should go into one cell in my table (except for the player 1 that goes to the first column). This part below ($pair_id .....) , is my attempt to create an array. This is where I need the help to setup appropriate array so that I can create my table. $pair_id[] = array( $related_user_1[ 0 ][ 'ID' ] => array( 'u2' => $related_user_2[ 0 ][ 'ID' ], 's1p1' => $set_1_player_1, 's1p2' => $set_1_player_2, 's2p1' => $set_2_player_1, 's2p2' => $set_2_player_2, 's3p1' => $set_3_player_1, 's3p2' => $set_3_player_2, ), );
  12. That's my problem with the code. I don't know how to fix or make the array so that I can use the data to generate the table. It does't have to be if you know a way to get the the table. Please feel free to change my code that I posted above to whatever you think it will work.
  13. Yes, S1P1 means Set1-Player1. It will show the result of the first set for the Player1 (which is the player in the first column). S1P2 is the result of Set1 for Player2. S2P1 is the result of Second set for player 1 S2P2 is the result of Second set for player 2. There are maximum of three sets per match. If there is no results it will show "-" until the result is posted. This is the how the final result should look like. I color coded the matches that are the same. For example, Kim and Tom played two matches. The result of first match are in the yellow box and the second match in the purple box. First match scores were as Tom 2 - Kim 6 Tom 1 - Kim 6 Second Match Scores Tom 6 - Kim 3 Tom 7 - Kim 6 They did not play the third set. Other scenarios in the table: - Mike and Kim only played once. They haven't played the second match yet. That's why they both have one box without match results (light green) - John and Tom played twice (Green and light blue). One match, they played three sets (Green) and one they played two sets (light blue). Also, the scores in each box are in specific order. The first score is for the player in the first column, the second score is for the player inside the cell. I hope this explains better.
  14. No, I'm asking how to put all the data from one match inside one cell using a loop. The following code works to create the table as in the previous thread: foreach ( $user as $u1 => $u2s ) { echo '<tr><td>' . $u1 . '</td>'; foreach ( $u2s as $x ) { echo '<td>' . $x . '</td>'; } echo '</tr>'; } What I need is on line #4 where I echo $x to show the opponents name, I also want to show the match results (s1p1, s2p2, ..... )
  15. I'm not looking to sort the data. I can show the data in any order and that's OK. I apologize if I didn't explain better. The final table is to show a an entire sport event results. . The first column on the left, is each player in that event [shown as number]. In front of each player, each cell, will represent one match, and each have data associated with that match (opponent name [shown as ID], match scores[s1-p1, ..... ] ). So, when player 4 plays a match with player 6, that match data will be shown in two boxes, once in front of player 4 and once in front of player 6. @Barand helped me to create a table for the players and that is working fine The problem that I have is to add the match results to each cell. That's what I'm trying to do. I hope this explains better. Thank you again for your time.
×
×
  • 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.