Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.90 KB | None | 0 0
  1. function wpr_editoffers()
  2. {
  3.      connect_db();
  4.     if (isset($_POST['savebutton'])) {
  5.         foreach ( $_POST['name'] as $key => $value ) {
  6.             print $key . " = " . $value . "<br>";
  7.         }
  8.         echo '<br>';
  9.         foreach ( $_POST['category'] as $key => $value ) {
  10.             print $key . " = " . $value . "<br>";
  11.         }
  12.         echo '<br>';
  13.         foreach ( $_POST['adress'] as $key => $value ) {
  14.             print $key . " = " . $value . "<br>";
  15.         }
  16.         echo '<br>';
  17.         foreach ( $_POST['postal_code'] as $key => $value ) {
  18.             print $key . " = " . $value . "<br>";
  19.         }
  20.         echo '<br>';
  21.         foreach ( $_POST['city'] as $key => $value ) {
  22.             print $key . " = " . $value . "<br>";
  23.         }
  24.         echo '<br>';
  25.         foreach ( $_POST['url'] as $key => $value ) {
  26.             print $key . " = " . $value . "<br>";
  27.         }
  28.         echo '<br>';
  29.         foreach ( $_POST['place_description'] as $key => $value ) {
  30.             print $key . " = " . $value . "<br>";
  31.         }
  32.         echo '<br>';
  33.         foreach ( $_POST['offer_description'] as $key => $value ) {
  34.             print $key . " = " . $value . "<br>";
  35.         }
  36.         echo '<br>';
  37.         foreach ( $_POST['price'] as $key => $value ) {
  38.             print $key . " = " . $value . "<br>";
  39.         }
  40.         echo '<br>';
  41.         foreach ( $_POST['stars'] as $key => $value ) {
  42.             print $key . " = " . $value . "<br>";
  43.         }
  44.         echo '<br>';
  45.         foreach ( $_POST['foodtype'] as $key => $value ) {
  46.             print $key . " = " . $value . "<br>";
  47.         }
  48.         echo '<br>';
  49.        
  50.         echo 'SQL FÖR ATT SPARA DESSA HÄR';
  51.         $savedb = TRUE;
  52.     }
  53.     if (isset($_GET['delete'])) {
  54.         mysql_query("DELETE from fm_offer WHERE offer_ID='".$_GET['delete']."'");
  55.         $delsubmit = true;
  56.     }
  57.     if (isset($_GET['edit'])) {
  58.         if(empty($_GET['new'])) {
  59.             $editerror = true;
  60.         }
  61.         else {
  62.             echo "SQL FOR EDITING " .$_GET['edit']. " to " .$_GET['new'] . " Here";
  63.             $editsubmit = true;
  64.         }
  65.     }
  66.  
  67.     $OfferType=array();
  68.     $sql=mysql_query ("SELECT * FROM fm_offer");
  69.    
  70.     while ($fetch = mysql_fetch_assoc($sql))
  71.     {
  72.             array_push($OfferType, $fetch);
  73.     }
  74.    
  75.    
  76.     ?>
  77.     <div id="icon-edit" class="icon32"></div>
  78.     <h2>Edit Offers</h2>
  79.     <form action="admin.php?page=editoffers" method="post">
  80.         <table class="widefat" id="listoffform">
  81.             <thead>
  82.                 <tr>
  83.                     <th>Name</th>
  84.                     <th>Category</th>
  85.                     <th>Adress</th>
  86.                     <th>URL</th>
  87.                     <th>Place Description</th>
  88.                     <th>Offer Description</th>
  89.                     <th>Price / Stars</th>
  90.                     <th>Foodtype</th>
  91.                     <th>Actions</th>
  92.                 </tr>
  93.             </thead>
  94.             <tfoot>
  95.                 <tr>
  96.                     <th>Name</th>
  97.                     <th>Category</th>
  98.                     <th>Adress</th>
  99.                     <th>URL</th>
  100.                     <th>Place Description</th>
  101.                     <th>Offer Description</th>
  102.                     <th>Price / Stars</th>
  103.                     <th>Foodtype</th>
  104.                     <th>Actions</th>
  105.                 </tr>
  106.             </tfoot>
  107.             <tbody>
  108.     <?php
  109.     foreach($OfferType as $result)
  110.     {
  111.     ?>
  112.                 <tr>
  113.                     <td id="1_<?php echo $result['name'] ;?>">
  114.                         <input type="text" size="15" name="name[]" value="<?php echo $result['name'] ; ?>"/>
  115.                     </td>
  116.                     <td id="1_<?php echo $result['category_ID'] ;?>">
  117.                         <input type="text" size="15" name="category[]" value="<?php echo $result['category_ID'] ;?>"/>
  118.                     </td>
  119.                     <td id="1_<?php echo $result['address'] ;?>">
  120.                         <input type="text" size="26" name="adress[]" value="<?php echo $result['address'] ;?>"/><br />
  121.                         <input type="text" size="6" name="postal_code[]" value="<?php echo $result['postal_code'] ;?>"/>
  122.                         <input type="text" size="12" name="city[]" value="<?php echo $result['city'] ;?>"/>
  123.                     </td>
  124.                    
  125.                     <td id="1_<?php echo $result['url'] ;?>">
  126.                         <input type="text" size="30" name="url[]" value="<?php echo $result['url'] ;?>"/>
  127.                     </td>
  128.                     <td id="1_<?php echo $result['place_description'] ;?>">
  129.                         <textarea name="place_description[]"><?php echo $result['place_description'] ;?></textarea>
  130.                     </td>
  131.                     <td id="1_<?php echo $result['offer_description'] ;?>">
  132.                         <textarea name="offer_description[]"><?php echo $result['offer_description'] ;?></textarea>
  133.                     </td>
  134.                     <td id="1_<?php echo $result['price'] ;?>">
  135.                         <input type="text" size="1" name="price[]" value="<?php if (empty($result['price'])) { echo "NULL"; } else  { echo $result['price']; }?>"/>  
  136.                         <input type="text" size="1" name="stars[]" value="<?php if (empty($result['stars'])) { echo "NULL"; } else  { echo $result['stars']; }?>"/>
  137.                     </td>
  138.                     <td id="1_<?php echo $result['foodtype'] ;?>">
  139.                         <input type="text" size="15" name="foodtype[]" value="<?php if (empty($result['foodtype'])) { echo "NULL"; } else  { echo $result['foodtype']; }?>"/>
  140.                     </td>
  141.                     <td>
  142.                         <a href='admin.php?page=editoffers&delete=<? echo $result['offer_ID'] ?>' onClick = "javascript: return confirm('Please confirm this action');">Delete</a>
  143.                     </td>
  144.                 </tr>
  145.     <?
  146.     }
  147.     ?>
  148.             </tbody>
  149.         </table>
  150.         <br />
  151.         <input class="button-primary" type="submit" name="savebutton" value="Save">
  152.         <a class="button-primary" href="admin.php?page=editoffers">Reset</a>
  153.     </form>
  154.    
  155.    
  156.    
  157.     <?php
  158.     if ($editerror) {
  159.         echo "<span style='color:red;'>A category cannot be empty. The action was not completed</span>";
  160.     }
  161.     ?>
  162.     <?php
  163.     if ($savedb) {
  164.         echo "<div id='message' class='updated'>
  165.             The changes have successfully been made.
  166.         </div>";
  167.     }
  168.     ?>
  169.     <?php
  170.     if ($delsubmit) {
  171.         echo "<div id='message' class='updated'>
  172.             You successfully deleted the offer with id
  173.             <b>". $_GET['delete'] ."</b> from the database
  174.         </div>";
  175.     }
  176.     ?>
  177.    
  178.    
  179.    
  180.     <script type="text/javascript">
  181.  
  182.         function save(event){
  183.             var original;
  184.             var updated;
  185.             original=event.srcElement.name;
  186.             updated=document.getElementsByName(original)[0].value;
  187.             var location=("admin.php?page=editcategory&edit=" + original +"&new=" +updated);
  188.             confirm('Please confirm this action');
  189.             this.location.href = location;
  190.         }
  191.     </script>
  192.     <?
  193. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement