Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.94 KB | None | 0 0
  1. <!-- Series Cars Stuff -->
  2. <?php
  3.  
  4. $posts = get_field('series_cars_reference');
  5. if( $posts ): ?>
  6.     <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
  7.         <?php setup_postdata($post); ?>
  8.             <form name="choose_car" method="POST" action="">   
  9.             <?php
  10.             $rows = get_field('cars');
  11.             if($rows) {
  12.                 echo '<select name="cars">';
  13.                 foreach($rows as $row)
  14.                 {
  15.                     echo '<option name="cars" value="' . $row['car'] . '">' . $row['car'] . '</option>';
  16.                 }
  17.             echo '</select>';
  18.             echo '<input type="submit" name="submit" value="Submit"/>';
  19.             }
  20.             $current_user = $current_user->display_name;           
  21.             $selectOption = Array(
  22.                 'name' => $current_user,
  23.                 'car' => $_POST['cars']
  24.             );
  25. echo '<pre>'; print_r($selectOption);echo '</pre>';
  26.             if(isset($_POST['submit'])){
  27.                 add_post_meta( get_the_ID(), 'entries', $selectOption );
  28.             }
  29.             ?>
  30.             </form>
  31.  
  32. <!-- SHOW ALL POST DATA - VAR DUMP PRINT -->   
  33. <h3>All Post Meta</h3>
  34. <?php $getPostCustom=get_post_custom(); // Get all the data ?>
  35. <?php
  36.     foreach($getPostCustom as $name=>$value) {
  37.         echo "<strong>".$name."</strong>"."  =>  ";
  38.         foreach($value as $nameAr=>$valueAr) {
  39.                 echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  40.                 echo $nameAr."  =>  ";
  41.                 echo var_dump($valueAr);
  42.         }
  43.         echo "<br /><br />";
  44.     }
  45. ?>
  46.  
  47. // BELOW IS WHAT THE OUTPUT PRINT VAR STUFF LOOKS LIKE:
  48. entries =>
  49.      0 =>
  50. string 'a:2:{s:4:"name";s:5:"admin";s:3:"car";s:20:"Mercedes SLS AMG GT3";}' (length=67)
  51.      1 =>
  52. string 'a:2:{s:4:"name";s:5:"admin";s:3:"car";s:20:"Mercedes SLS AMG GT3";}' (length=67)
  53.      2 =>
  54. string 'a:2:{s:4:"name";s:5:"admin";s:3:"car";s:20:"Mercedes SLS AMG GT3";}' (length=67)
  55.      3 =>
  56. string 'a:2:{s:4:"name";N;s:3:"car";s:20:"Mercedes SLS AMG GT3";}' (length=57)
  57.      4 =>
  58. string 'a:2:{s:4:"name";N;s:3:"car";s:20:"Mercedes SLS AMG GT3";}' (length=57)
  59.      5 =>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement