Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wpr_editoffers()
- {
- connect_db();
- if (isset($_POST['savebutton'])) {
- foreach ( $_POST['name'] as $key => $value ) {
- print $key . " = " . $value . "<br>";
- }
- echo '<br>';
- foreach ( $_POST['category'] as $key => $value ) {
- print $key . " = " . $value . "<br>";
- }
- echo '<br>';
- foreach ( $_POST['adress'] as $key => $value ) {
- print $key . " = " . $value . "<br>";
- }
- echo '<br>';
- foreach ( $_POST['postal_code'] as $key => $value ) {
- print $key . " = " . $value . "<br>";
- }
- echo '<br>';
- foreach ( $_POST['city'] as $key => $value ) {
- print $key . " = " . $value . "<br>";
- }
- echo '<br>';
- foreach ( $_POST['url'] as $key => $value ) {
- print $key . " = " . $value . "<br>";
- }
- echo '<br>';
- foreach ( $_POST['place_description'] as $key => $value ) {
- print $key . " = " . $value . "<br>";
- }
- echo '<br>';
- foreach ( $_POST['offer_description'] as $key => $value ) {
- print $key . " = " . $value . "<br>";
- }
- echo '<br>';
- foreach ( $_POST['price'] as $key => $value ) {
- print $key . " = " . $value . "<br>";
- }
- echo '<br>';
- foreach ( $_POST['stars'] as $key => $value ) {
- print $key . " = " . $value . "<br>";
- }
- echo '<br>';
- foreach ( $_POST['foodtype'] as $key => $value ) {
- print $key . " = " . $value . "<br>";
- }
- echo '<br>';
- echo 'SQL FÖR ATT SPARA DESSA HÄR';
- $savedb = TRUE;
- }
- if (isset($_GET['delete'])) {
- mysql_query("DELETE from fm_offer WHERE offer_ID='".$_GET['delete']."'");
- $delsubmit = true;
- }
- if (isset($_GET['edit'])) {
- if(empty($_GET['new'])) {
- $editerror = true;
- }
- else {
- echo "SQL FOR EDITING " .$_GET['edit']. " to " .$_GET['new'] . " Here";
- $editsubmit = true;
- }
- }
- $OfferType=array();
- $sql=mysql_query ("SELECT * FROM fm_offer");
- while ($fetch = mysql_fetch_assoc($sql))
- {
- array_push($OfferType, $fetch);
- }
- ?>
- <div id="icon-edit" class="icon32"></div>
- <h2>Edit Offers</h2>
- <form action="admin.php?page=editoffers" method="post">
- <table class="widefat" id="listoffform">
- <thead>
- <tr>
- <th>Name</th>
- <th>Category</th>
- <th>Adress</th>
- <th>URL</th>
- <th>Place Description</th>
- <th>Offer Description</th>
- <th>Price / Stars</th>
- <th>Foodtype</th>
- <th>Actions</th>
- </tr>
- </thead>
- <tfoot>
- <tr>
- <th>Name</th>
- <th>Category</th>
- <th>Adress</th>
- <th>URL</th>
- <th>Place Description</th>
- <th>Offer Description</th>
- <th>Price / Stars</th>
- <th>Foodtype</th>
- <th>Actions</th>
- </tr>
- </tfoot>
- <tbody>
- <?php
- foreach($OfferType as $result)
- {
- ?>
- <tr>
- <td id="1_<?php echo $result['name'] ;?>">
- <input type="text" size="15" name="name[]" value="<?php echo $result['name'] ; ?>"/>
- </td>
- <td id="1_<?php echo $result['category_ID'] ;?>">
- <input type="text" size="15" name="category[]" value="<?php echo $result['category_ID'] ;?>"/>
- </td>
- <td id="1_<?php echo $result['address'] ;?>">
- <input type="text" size="26" name="adress[]" value="<?php echo $result['address'] ;?>"/><br />
- <input type="text" size="6" name="postal_code[]" value="<?php echo $result['postal_code'] ;?>"/>
- <input type="text" size="12" name="city[]" value="<?php echo $result['city'] ;?>"/>
- </td>
- <td id="1_<?php echo $result['url'] ;?>">
- <input type="text" size="30" name="url[]" value="<?php echo $result['url'] ;?>"/>
- </td>
- <td id="1_<?php echo $result['place_description'] ;?>">
- <textarea name="place_description[]"><?php echo $result['place_description'] ;?></textarea>
- </td>
- <td id="1_<?php echo $result['offer_description'] ;?>">
- <textarea name="offer_description[]"><?php echo $result['offer_description'] ;?></textarea>
- </td>
- <td id="1_<?php echo $result['price'] ;?>">
- <input type="text" size="1" name="price[]" value="<?php if (empty($result['price'])) { echo "NULL"; } else { echo $result['price']; }?>"/>
- <input type="text" size="1" name="stars[]" value="<?php if (empty($result['stars'])) { echo "NULL"; } else { echo $result['stars']; }?>"/>
- </td>
- <td id="1_<?php echo $result['foodtype'] ;?>">
- <input type="text" size="15" name="foodtype[]" value="<?php if (empty($result['foodtype'])) { echo "NULL"; } else { echo $result['foodtype']; }?>"/>
- </td>
- <td>
- <a href='admin.php?page=editoffers&delete=<? echo $result['offer_ID'] ?>' onClick = "javascript: return confirm('Please confirm this action');">Delete</a>
- </td>
- </tr>
- <?
- }
- ?>
- </tbody>
- </table>
- <br />
- <input class="button-primary" type="submit" name="savebutton" value="Save">
- <a class="button-primary" href="admin.php?page=editoffers">Reset</a>
- </form>
- <?php
- if ($editerror) {
- echo "<span style='color:red;'>A category cannot be empty. The action was not completed</span>";
- }
- ?>
- <?php
- if ($savedb) {
- echo "<div id='message' class='updated'>
- The changes have successfully been made.
- </div>";
- }
- ?>
- <?php
- if ($delsubmit) {
- echo "<div id='message' class='updated'>
- You successfully deleted the offer with id
- <b>". $_GET['delete'] ."</b> from the database
- </div>";
- }
- ?>
- <script type="text/javascript">
- function save(event){
- var original;
- var updated;
- original=event.srcElement.name;
- updated=document.getElementsByName(original)[0].value;
- var location=("admin.php?page=editcategory&edit=" + original +"&new=" +updated);
- confirm('Please confirm this action');
- this.location.href = location;
- }
- </script>
- <?
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement