Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Add, Update and Delete on one form will not work

    Hi,
    I have a page on which data is displayed via clicking a record hyperlink on another page. The user can change the record details or add a new record. I want them to be able to delete a record as well and this is where I have come unstuck..

    The form originally had 2 buttons, one SUBMIT which will either UPDATE or ADD a new record which both work fine. I have added a DELETE button so that a retrieved record can be deleted entirely but am battling to get it to actually delete the record. I get the message 'Query was Empty'. I have verified that the variable I am using in the delete query has the correct value taken from the url but just cannot get it to work.. is probably right under my nose but yet I cannot see it... can anyone with eagle eyes see what I have done wrong? Would appreciate any help...

    If I substitute WHERE id = '$roomid'"; with WHERE id = 3"; with 3 being the actual ID of the record, then the delete statement works fine..
    My code looks like this (have edited it down as too many characters for the post)..

    Code:
    <?php
     include '../dbfunctions.php';
     
      session_start();
     
      $link = dbConnect();
    
      checkVenueLogin();
     
      if( isset($_POST['Submit']) ) {
    
        $facs = "";
        foreach( $_POST as $k => $v )
          if( substr($k,0,4) == "fac_" ) $facs .= $v;
      
        if( $_POST['roomid'] == "" ) //new room
          $query = "INSERT INTO roomcategories (`venueid`, `roomname`, `class`, `nobeds`, `bedtype`, `sleeps`, `basis`, `facilities`,`mixed`, `description`) VALUES ('".$_SESSION['venueid']."', '".$_POST['roomname']."', '".$_POST['class']."', '".$_POST['nobeds']."', '".$_POST['bedtype']."', '".$_POST['sleeps']."', '".$_POST['basis']."', '".$facs."', '".$_POST['mixed']."', '".$_POST['description']."')";
        else //update
          $query = "UPDATE roomcategories SET `roomname` = '".$_POST['roomname']."', `class` = '".$_POST['class']."', `nobeds` = '".$_POST['nobeds']."', `bedtype` = '".$_POST['bedtype']."', `sleeps` = '".$_POST['sleeps']."', `basis` = '".$_POST['basis']."', `facilities` = '".$facs."', `mixed` = '".$_POST['mixed']."', `description` = '".$_POST['description']."' WHERE id = '".$roomid."'";
    	}  
    	elseif(isset($_POST['delete']))
     {
     $sql = "DELETE FROM `roomcategories` WHERE id = '$roomid'";  
     $result = mysql_query($sql) or die( "Error: " . mysql_error() );
    }
    
      if( $_POST['roomname'] != "" ) $result = mysql_query($query, $link) or die("Query failed : ".$query."<br>". mysql_error());
     // }
      
     if( isset($_GET['id']) ) $roomid = $_GET['id']; else $roomid = "";
    
      $rooms = dbGetRows("roomcategories", "id = '".$roomid."'");
      $room = mysql_fetch_array($rooms, MYSQL_ASSOC);
      
      $venues = dbGetRows("venues", "id = '".$_SESSION['venueid']."'");
      $venue = mysql_fetch_array($venues, MYSQL_ASSOC);
      
      $roomid = $_GET['id']; 
      echo $roomid; 
    ?>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Modify Room</title>
    <link href="../bb.css" rel="stylesheet" type="text/css">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body bgcolor="#FFF4DC" <?php if(isset($_POST['Submit']) && $result) echo "onLoad=\"window.close(); opener.location.reload(true);\""; ?>>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
      <tr> 
        <td width="32"><img src="images/admin_03.gif"></td>
        <td width="0*" bgcolor="#FFFFFF" background="images/admin_04.gif" style="background-repeat: repeat-x;">&nbsp;</td>
        <td width="35"><img src="images/admin_07.gif" width="32" height="33"></td>
      </tr>
      <tr> 
        <td bgcolor="#FFFFFF" background="images/admin_15.gif" style="background-repeat: repeat-y;"></td>
        <td bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-left: 10px; margin-right: 10px;">
            <tr> 
              <td>
                <font size="3"><b> 
                <?php if( $roomid != "") echo "MODIFY CATEGORY"; else echo "ADD NEW CATEGORY"; ?>
                </b></font><br>
                <font size=1>
                Enter a category below to specify a type of room available at your venue.<br>
                E.g. You could create a 'standard' room type which would be used to describe all three of your 'standard' room.</font><br>
                <br> 
                <?php
      if( isset($_POST['roomname']) && $_POST['roomname'] == "") echo "<font color=\"#FF0000\">Please enter a room name!</font><br><br>";
     
      if(isset($_POST['Delete']) && $result) {
        echo "<font size=\"3\"><b>UPDATE SUCCESSFUL</b></font><br><br>
        Your details have been updated.<br><br>
       <a href=\"javascript:;\" onClick=\"window.close(); opener.location.reload(true);\">[CLOSE WINDOW]</a></a><br>    
        </td>
        <td bgcolor=\"#FFFFFF\" align=\"right\" background=\"images/admin_14.gif\" style=\"background-position: right; background-repeat: repeat-y;\"></td>
      </tr>
      <tr> 
        <td><img src=\"images/admin_21.gif\" width=\"32\" height=\"33\"></td>
        <td bgcolor=\"#FFFFFF\" background=\"images/admin_23.gif\" style=\"background-position: bottom; background-repeat: repeat-x;\"></td>
        <td><img src=\"images/admin_20.gif\" width=\"32\" height=\"33\"></td>
      </tr>
    </table>
    </body></html>";
        die();
      }
    ?>
                <form name="form1" method="post" action="modifyroom.php">
                  <table width="449" border="0" cellspacing="0" cellpadding="2">
                    <tr> 
                      <td width="104"><b>Room Type Name</b></td>
                      <td width="235" valign="top"><input type="text" name="roomname" value="<?php echo $room['roomname']; ?>"> 
                      <a href="javascript:;" onClick="alert('Enter a descriptive name for this room type\n\nExamples could be `Luxury Room` or `Standard Room` or `Sea-Facing Room`');">[?]</a><input type="hidden" name="roomid" value="<?php echo $roomid; ?>">                  </td>
                    </tr>
                    <tr> 
                      <td valign="top"><b>Description</b></td>
                      <td valign="top"><textarea name="description"><?php echo $room['description']; ?></textarea>
                        <a href="javascript:;" onClick="alert('Enter full description for this type of room\n\nAn example could be `A luxury room with en-suite and majestic views over the valley.`');">[?]</a></td>
                    </tr>
                    <tr> 
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                    <tr> 
                      <td><b> Room Class</b></td>
                      <td> <select name="class">
                          <option value="stateroom" <?php if($room['class'] == "stateroom") echo "selected"; ?>>Stateroom</option>
                          <option value="suite" <?php if($room['class'] == "suite") echo "selected"; ?>>Suite</option>
                          <option value="superior" <?php if($room['class'] == "superior") echo "selected"; ?>>Superior</option>
                          <option value="first class" <?php if($room['class'] == "first class") echo "selected"; ?>>First 
                          Class</option>
                          <option value="standard" <?php if($room['class'] == "standard") echo "selected"; ?>>Standard</option>
                          <option value="budget" <?php if($room['class'] == "budget") echo "selected"; ?>>Budget</option>
                          <option value="dormitory" <?php if($room['class'] == "dormitory") echo "selected"; ?>>Dormitory</option>
                          <option value="caravan" <?php if($room['class'] == "caravan") echo "selected"; ?>>Caravan</option> 
                          <option vlue="Trailer" <?php if($room['class'] == "trailer") echo "selected"; ?>>Trailer</option>
                          <option vlue="Tent" <?php if($room['class'] == "tent") echo "selected"; ?>>Tent</option>
                        </select></td>
                    </tr>
                    <tr> 
                      <td><b>No. of Beds</b></td>
                      <td><select name="nobeds">
                          <option value="1" <?php if( $room['nobeds'] == "1") echo "selected"; ?>>1</option>
                          <option value="2" <?php if( $room['nobeds'] == "2") echo "selected"; ?>>2</option>
                          <option value="3" <?php if( $room['nobeds'] == "3") echo "selected"; ?>>3</option>
                          <option value="4" <?php if( $room['nobeds'] == "4") echo "selected"; ?>>4</option>
                          <option value="5" <?php if( $room['nobeds'] == "5") echo "selected"; ?>>5</option>
                          <option value="6" <?php if( $room['nobeds'] == "6") echo "selected"; ?>>6</option>
                          <option value="7" <?php if( $room['nobeds'] == "7") echo "selected"; ?>>7</option>
                          <option value="8" <?php if( $room['nobeds'] == "8") echo "selected"; ?>>8</option>
                          <option value="9" <?php if( $room['nobeds'] == "9") echo "selected"; ?>>9</option>
                          <option value="10" <?php if( $room['nobeds'] == "10") echo "selected"; ?>>10</option>
                          <option value="11" <?php if( $room['nobeds'] == "11") echo "selected"; ?>>11</option>
                          <option value="12" <?php if( $room['nobeds'] == "12") echo "selected"; ?>>12</option>
                          <option value="13" <?php if( $room['nobeds'] == "13") echo "selected"; ?>>13</option>
                          <option value="14" <?php if( $room['nobeds'] == "14") echo "selected"; ?>>14</option>
                          <option value="15" <?php if( $room['nobeds'] == "15") echo "selected"; ?>>15</option>
                          <option value="16" <?php if( $room['nobeds'] == "16") echo "selected"; ?>>16</option>
                          <option value="17" <?php if( $room['nobeds'] == "17") echo "selected"; ?>>17</option>
                          <option value="18" <?php if( $room['nobeds'] == "18") echo "selected"; ?>>18</option>
                          <option value="19" <?php if( $room['nobeds'] == "19") echo "selected"; ?>>19</option>
                          <option value="20" <?php if( $room['nobeds'] == "20") echo "selected"; ?>>20</option>
                          <option value="21" <?php if( $room['nobeds'] == "21") echo "selected"; ?>>21</option>
                          <option value="22" <?php if( $room['nobeds'] == "22") echo "selected"; ?>>22</option>
                          <option value="23" <?php if( $room['nobeds'] == "23") echo "selected"; ?>>23</option>
                          <option value="24" <?php if( $room['nobeds'] == "24") echo "selected"; ?>>24</option>
                          <option value="25" <?php if( $room['nobeds'] == "25") echo "selected"; ?>>25</option>
                          <option value="26" <?php if( $room['nobeds'] == "26") echo "selected"; ?>>26</option>
                          <option value="27" <?php if( $room['nobeds'] == "27") echo "selected"; ?>>27</option>
                          <option value="28" <?php if( $room['nobeds'] == "28") echo "selected"; ?>>28</option>
                          <option value="29" <?php if( $room['nobeds'] == "29") echo "selected"; ?>>29</option>
                          <option value="30" <?php if( $room['nobeds'] == "30") echo "selected"; ?>>30</option>
                        </select></td>
                    </tr>
                    <tr> 
                      <td><b>Type of Bed(s)</b></td>
                      <td> <select name="bedtype">
                          <option value="queen" <?php if($room['bedtype'] == "queen") echo "selected"; ?>>Queen</option>
                          <option value="king" <?php if($room['bedtype'] == "king") echo "selected"; ?>>King</option>
                          <option value="double" <?php if($room['bedtype'] == "double") echo "selected"; ?>>Double</option>
                          <option value="three-quarter" <?php if($room['bedtype'] == "three-quarter") echo "selected"; ?>>Three-Quarter</option>
                          <option value="single" <?php if($room['bedtype'] == "single") echo "selected"; ?>>Single</option>
                          <option value="bunk" <?php if($room['bedtype'] == "bunk") echo "selected"; ?>>Bunk</option>
                          <option value="berth" <?php if($room['bedtype'] == "berth") echo "selected"; ?>>Berth</option>
                          <option value="mixed" <?php if($room['bedtype'] == "mixed") echo "selected"; ?>>Mixed</option>
                        </select></td>
                    </tr>
                    <tr> 
                      <td><b>Sleeps</b></td>
                      <td><select name="sleeps">
                        <option value="1" <?php if( $room['sleeps'] == "1") echo "selected"; ?>>1</option>
                        <option value="2" <?php if( $room['sleeps'] == "2") echo "selected"; ?>>2</option>
                             </select></td>
                    </tr>
                    <tr>
                      <td><strong>How Do you charge for this room?</strong></td>
                      <td><select name="basis">
                    <option value="per room" <?php if( $room['basis'] == "per room") echo "selected"; ?>>Per Room</option>
                    <option value="per person" <?php if( $room['basis'] == "per person") echo "selected"; ?>>Per Person</option>
                  </select>      </td>
                    </tr>
                    <tr>
                      <td><strong>Mixed</strong></td>
                      <td><label>
                        <select name="mixed">
                          <option value="yes" <?php if( $room['mixed'] == "yes") echo "selected"; ?>>Yes</option>
                          <option value="no" <?php if( $room['mixed'] == "no") echo "selected"; ?>>No</option>
                        </select>
                      </label></td>
                    </tr>
                    <tr> 
                      <td colspan="2"><strong>Please note</strong>: If you charge a base rate for the room <strong>PLUS</strong> a per person rate then select &quot;<strong>Yes</strong>&quot; above.</td>
                    </tr>
                  </table>
                  <br>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td align="right">&nbsp;</td>
                    </tr>
                    <tr> 
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td align="right"><input type="submit" name="Submit" value="Add / Update">
                        <input type="button" name="Cancel" value="Close Window" onClick="window.close();">
                        <label>
                        <input type="submit" name="delete"  value="Delete Room">
                        </label></td>
                    </tr>
                    <tr> 
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                  </table>
                </form>
            </table></td>
    Last edited by garwil; 06-07-2011 at 03:44 PM.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Variable $roomid is not assigned a value until after the DELETE query runs. I don't see how that will ever work.

  • #3
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Fumigator,

    Many thanks for taking the time to reply to my post. Since my post to the forum I did realise that the declaration is taking place after the delete statement and since moved it to the correct location. However my var_dump($query); is still indicating that the variable contains nothing as per this string(41) "DELETE FROM roomcategories WHERE id = '' " (I have no idea what the string (41) means. When I echo the variable I am getting the correct value returned.
    I don't know what else could be causing this...

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Let me see your most updated code.

  • #5
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,
    Thanks for your time.. I have been trying various things and am now at this point.. still with my $var dump showing an empty value...
    Code:
    <?php
     include '../dbfunctions.php';
     
      session_start();
     
      $link = dbConnect();
    
      checkVenueLogin();
      
      if( isset($_GET['id']) )
      $roomid = $_GET['id'];
      
      else $roomid = "";
      echo $roomid; 
      
      $rooms = dbGetRows("roomcategories", "id = '".$roomid."'");
      $room = mysql_fetch_array($rooms, MYSQL_ASSOC);
      
      $venues = dbGetRows("venues", "id = '".$_SESSION['venueid']."'");
      $venue = mysql_fetch_array($venues, MYSQL_ASSOC);
        if(isset($_POST['delete']))
     {
      $query = ("DELETE FROM roomcategories WHERE id = '$roomid'");
      var_dump($query); 
     //$result = mysql_query($query) or die( "Error: " . mysql_error() );
    }
     
      if( isset($_POST['Submit']) ) {
    
        $facs = "";
        foreach( $_POST as $k => $v )
          if( substr($k,0,4) == "fac_" ) $facs .= $v;
      
        if( $_POST['roomid'] == "" ) //new room
          $query = "INSERT INTO roomcategories (`venueid`, `roomname`, `class`, `nobeds`, `bedtype`, `sleeps`, `basis`, `facilities`,`mixed`, `description`) VALUES ('".$_SESSION['venueid']."', '".$_POST['roomname']."', '".$_POST['class']."', '".$_POST['nobeds']."', '".$_POST['bedtype']."', '".$_POST['sleeps']."', '".$_POST['basis']."', '".$facs."', '".$_POST['mixed']."', '".$_POST['description']."')";
        else //update
          $query = "UPDATE roomcategories SET `roomname` = '".$_POST['roomname']."', `class` = '".$_POST['class']."', `nobeds` = '".$_POST['nobeds']."', `bedtype` = '".$_POST['bedtype']."', `sleeps` = '".$_POST['sleeps']."', `basis` = '".$_POST['basis']."', `facilities` = '".$facs."', `mixed` = '".$_POST['mixed']."', `description` = '".$_POST['description']."' WHERE id = '".$roomid."'";
    
        if( $_POST['roomname'] != "" ) $result = mysql_query($query, $link) or die("Query failed : ".$query."<br>". mysql_error());
      }
        
    ?>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Modify Room</title>
    <link href="../bb.css" rel="stylesheet" type="text/css">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body bgcolor="#FFF4DC"
    <?php if(isset($_POST['Submit']) && $result) echo "onLoad=\"window.close(); opener.location.reload(true);\""; ?>>
    
    <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
      <tr> 
        <td width="32"><img src="images/admin_03.gif"></td>
        <td width="0*" bgcolor="#FFFFFF" background="images/admin_04.gif" style="background-repeat: repeat-x;">&nbsp;</td>
        <td width="35"><img src="images/admin_07.gif" width="32" height="33"></td>
      </tr>
      <tr> 
        <td bgcolor="#FFFFFF" background="images/admin_15.gif" style="background-repeat: repeat-y;"></td>
        <td bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-left: 10px; margin-right: 10px;">
            <tr> 
              <td>
                <font size="3"><b> 
                <?php if( $roomid != "") echo "MODIFY CATEGORY"; else echo "ADD NEW CATEGORY"; ?>
                </b></font><br>
                <font size=1>
                Enter a category below to specify a type of room available at your venue.<br>
                E.g. You could create a 'standard' room type which would be used to describe all three of your 'standard' room.</font><br>
                <br> 
                <?php
      if( isset($_POST['roomname']) && $_POST['roomname'] == "") echo "<font color=\"#FF0000\">Please enter a room name!</font><br><br>";
    ?>
                <form name="form1" method="post" action="modifyroom.php">
                  <table width="449" border="0" cellspacing="0" cellpadding="2">
                    <tr> 
                      <td width="104"><b>Room Type Name</b></td>
                      <td width="235" valign="top"><input type="text" name="roomname" value="<?php echo $room['roomname']; ?>"> 
                      <a href="javascript:;" onClick="alert('Enter a descriptive name for this room type\n\nExamples could be `Luxury Room` or `Standard Room` or `Sea-Facing Room`');">[?]</a><input type="hidden" name="roomid" value="<?php echo $roomid; ?>">                  </td>
                    </tr>
                    <tr> 
                      <td valign="top"><b>Description</b></td>
                      <td valign="top"><textarea name="description"><?php echo $room['description']; ?></textarea>
                        <a href="javascript:;" onClick="alert('Enter full description for this type of room\n\nAn example could be `A luxury room with en-suite and majestic views over the valley.`');">[?]</a></td>
                    </tr>
                    <tr> 
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                    <tr> 
                      <td><b> Room Class</b></td>
                      <td> <select name="class">
                          <option value="stateroom" <?php if($room['class'] == "stateroom") echo "selected"; ?>>Stateroom</option>
                          <option value="suite" <?php if($room['class'] == "suite") echo "selected"; ?>>Suite</option>
                          <option value="superior" <?php if($room['class'] == "superior") echo "selected"; ?>>Superior</option>
                          <option value="first class" <?php if($room['class'] == "first class") echo "selected"; ?>>First 
                          Class</option>
                          <option value="standard" <?php if($room['class'] == "standard") echo "selected"; ?>>Standard</option>
                          <option value="budget" <?php if($room['class'] == "budget") echo "selected"; ?>>Budget</option>
                          <option value="dormitory" <?php if($room['class'] == "dormitory") echo "selected"; ?>>Dormitory</option>
                          <option value="caravan" <?php if($room['class'] == "caravan") echo "selected"; ?>>Caravan</option> 
                          <option vlue="Trailer" <?php if($room['class'] == "trailer") echo "selected"; ?>>Trailer</option>
                          <option vlue="Tent" <?php if($room['class'] == "tent") echo "selected"; ?>>Tent</option>
                        </select></td>
                    </tr>
                    <tr> 
                      <td><b>No. of Beds</b></td>
                      <td><select name="nobeds">
                          <option value="1" <?php if( $room['nobeds'] == "1") echo "selected"; ?>>1</option>
                          <option value="2" <?php if( $room['nobeds'] == "2") echo "selected"; ?>>2</option>
                          <option value="3" <?php if( $room['nobeds'] == "3") echo "selected"; ?>>3</option>
                          <option value="4" <?php if( $room['nobeds'] == "4") echo "selected"; ?>>4</option>
                          <option value="5" <?php if( $room['nobeds'] == "5") echo "selected"; ?>>5</option>
                          <option value="6" <?php if( $room['nobeds'] == "6") echo "selected"; ?>>6</option>
                          <option value="7" <?php if( $room['nobeds'] == "7") echo "selected"; ?>>7</option>
                          <option value="8" <?php if( $room['nobeds'] == "8") echo "selected"; ?>>8</option>
                          <option value="9" <?php if( $room['nobeds'] == "9") echo "selected"; ?>>9</option>
                          <option value="10" <?php if( $room['nobeds'] == "10") echo "selected"; ?>>10</option>
                          <option value="11" <?php if( $room['nobeds'] == "11") echo "selected"; ?>>11</option>
                          <option value="12" <?php if( $room['nobeds'] == "12") echo "selected"; ?>>12</option>
                          <option value="13" <?php if( $room['nobeds'] == "13") echo "selected"; ?>>13</option>
                          <option value="14" <?php if( $room['nobeds'] == "14") echo "selected"; ?>>14</option>
                          <option value="15" <?php if( $room['nobeds'] == "15") echo "selected"; ?>>15</option>
                          <option value="16" <?php if( $room['nobeds'] == "16") echo "selected"; ?>>16</option>
                          <option value="17" <?php if( $room['nobeds'] == "17") echo "selected"; ?>>17</option>
                          <option value="18" <?php if( $room['nobeds'] == "18") echo "selected"; ?>>18</option>
                          <option value="19" <?php if( $room['nobeds'] == "19") echo "selected"; ?>>19</option>
                          <option value="20" <?php if( $room['nobeds'] == "20") echo "selected"; ?>>20</option>
                          <option value="21" <?php if( $room['nobeds'] == "21") echo "selected"; ?>>21</option>
                          <option value="22" <?php if( $room['nobeds'] == "22") echo "selected"; ?>>22</option>
                          <option value="23" <?php if( $room['nobeds'] == "23") echo "selected"; ?>>23</option>
                          <option value="24" <?php if( $room['nobeds'] == "24") echo "selected"; ?>>24</option>
                          <option value="25" <?php if( $room['nobeds'] == "25") echo "selected"; ?>>25</option>
                          <option value="26" <?php if( $room['nobeds'] == "26") echo "selected"; ?>>26</option>
                          <option value="27" <?php if( $room['nobeds'] == "27") echo "selected"; ?>>27</option>
                          <option value="28" <?php if( $room['nobeds'] == "28") echo "selected"; ?>>28</option>
                          <option value="29" <?php if( $room['nobeds'] == "29") echo "selected"; ?>>29</option>
                          <option value="30" <?php if( $room['nobeds'] == "30") echo "selected"; ?>>30</option>
                        </select></td>
                    </tr>
                    <tr> 
                      <td><b>Type of Bed(s)</b></td>
                      <td> <select name="bedtype">
                          <option value="queen" <?php if($room['bedtype'] == "queen") echo "selected"; ?>>Queen</option>
                          <option value="king" <?php if($room['bedtype'] == "king") echo "selected"; ?>>King</option>
                          <option value="double" <?php if($room['bedtype'] == "double") echo "selected"; ?>>Double</option>
                          <option value="three-quarter" <?php if($room['bedtype'] == "three-quarter") echo "selected"; ?>>Three-Quarter</option>
                          <option value="single" <?php if($room['bedtype'] == "single") echo "selected"; ?>>Single</option>
                          <option value="bunk" <?php if($room['bedtype'] == "bunk") echo "selected"; ?>>Bunk</option>
                          <option value="berth" <?php if($room['bedtype'] == "berth") echo "selected"; ?>>Berth</option>
                          <option value="mixed" <?php if($room['bedtype'] == "mixed") echo "selected"; ?>>Mixed</option>
                        </select></td>
                    </tr>
                    <tr> 
                      <td><b>Sleeps</b></td>
                      <td><select name="sleeps">
                        <option value="1" <?php if( $room['sleeps'] == "1") echo "selected"; ?>>1</option>
                        <option value="2" <?php if( $room['sleeps'] == "2") echo "selected"; ?>>2</option>
                        <option value="3" <?php if( $room['sleeps'] == "3") echo "selected"; ?>>3</option>
                        <option value="4" <?php if( $room['sleeps'] == "4") echo "selected"; ?>>4</option>
                        <option value="5" <?php if( $room['sleeps'] == "5") echo "selected"; ?>>5</option>
                        <option value="6" <?php if( $room['sleeps'] == "6") echo "selected"; ?>>6</option>
                        <option value="7" <?php if( $room['sleeps'] == "7") echo "selected"; ?>>7</option>
                        <option value="8" <?php if( $room['sleeps'] == "8") echo "selected"; ?>>8</option>
                        <option value="9" <?php if( $room['sleeps'] == "9") echo "selected"; ?>>9</option>
                        <option value="10" <?php if( $room['sleeps'] == "10") echo "selected"; ?>>10</option>
                        <option value="11" <?php if( $room['sleeps'] == "11") echo "selected"; ?>>11</option>
                        <option value="12" <?php if( $room['sleeps'] == "12") echo "selected"; ?>>12</option>
                        <option value="13" <?php if( $room['sleeps'] == "13") echo "selected"; ?>>13</option>
                        <option value="14" <?php if( $room['sleeps'] == "14") echo "selected"; ?>>14</option>
                        <option value="15" <?php if( $room['sleeps'] == "15") echo "selected"; ?>>15</option>
                        <option value="16" <?php if( $room['sleeps'] == "16") echo "selected"; ?>>16</option>
                        <option value="17" <?php if( $room['sleeps'] == "17") echo "selected"; ?>>17</option>
                        <option value="18" <?php if( $room['sleeps'] == "18") echo "selected"; ?>>18</option>
                        <option value="19" <?php if( $room['sleeps'] == "19") echo "selected"; ?>>19</option>
                        <option value="20" <?php if( $room['sleeps'] == "20") echo "selected"; ?>>20</option>
                        <option value="21" <?php if( $room['sleeps'] == "21") echo "selected"; ?>>21</option>
                        <option value="22" <?php if( $room['sleeps'] == "22") echo "selected"; ?>>22</option>
                        <option value="23" <?php if( $room['sleeps'] == "23") echo "selected"; ?>>23</option>
                        <option value="24" <?php if( $room['sleeps'] == "24") echo "selected"; ?>>24</option>
                        <option value="25" <?php if( $room['sleeps'] == "25") echo "selected"; ?>>25</option>
                        <option value="26" <?php if( $room['sleeps'] == "26") echo "selected"; ?>>26</option>
                        <option value="27" <?php if( $room['sleeps'] == "27") echo "selected"; ?>>27</option>
                        <option value="28" <?php if( $room['sleeps'] == "28") echo "selected"; ?>>28</option>
                        <option value="29" <?php if( $room['sleeps'] == "29") echo "selected"; ?>>29</option>
                        <option value="30" <?php if( $room['sleeps'] == "30") echo "selected"; ?>>30</option>
                      </select></td>
                    </tr>
                    <tr>
                      <td><strong>How Do you charge for this room?</strong></td>
                      <td><select name="basis">
                    <option value="per room" <?php if( $room['basis'] == "per room") echo "selected"; ?>>Per Room</option>
                    <option value="per person" <?php if( $room['basis'] == "per person") echo "selected"; ?>>Per Person</option>
                  </select>      </td>
                    </tr>
                    <tr>
                      <td><strong>Mixed</strong></td>
                      <td><label>
                        <select name="mixed">
                          <option value="yes" <?php if( $room['mixed'] == "yes") echo "selected"; ?>>Yes</option>
                          <option value="no" <?php if( $room['mixed'] == "no") echo "selected"; ?>>No</option>
                        </select>
                      </label></td>
                    </tr>
                    <tr> 
                      <td colspan="2"><strong>Please note</strong>: If you charge a base rate for the room <strong>PLUS</strong> a per person rate then select &quot;<strong>Yes</strong>&quot; above.</td>
                    </tr>
                  </table>
                  <br>
                  <b>ROOM FACILITIES</b><br>
                  <table width="448" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td width="28" align="center"><input type="checkbox" name="fac_tel" value="l" <?php if( strpos($room['facilities'], "l") > -1) echo "checked"; ?>></td>
                      <td width="53" align="center"><img src="images/icons/ico_phone.gif" width="26" height="27"></td>
                      <td width="219" class="small">Telephone</td>
                    </tr>
                    <tr> 
                      <td align="center"><input type="checkbox" name="fac_safe" value="f" <?php if( strpos($room['facilities'], "f") > -1) echo "checked"; ?>></td>
                      <td align="center"><img src="images/icons/ico_safe.gif" width="26" height="27"></td>
                      <td class="small">Safe</td>
                    </tr>
                    <tr> 
                      <td align="center"><input type="checkbox" name="fac_smoke" value="s" <?php if( strpos($room['facilities'], "s") > -1) echo "checked"; ?>></td>
                      <td align="center"><img src="images/icons/ico_smoke.gif" width="26" height="27"></td>
                      <td class="small">Smoking Permitted</td>
                    </tr>
                    <tr> 
                      <td align="center"><input type="checkbox" name="fac_tv" value="m" <?php if( strpos($room['facilities'], "t") > -1) echo "checked"; ?>></td>
                      <td align="center"><div align="center"><img src="images/icons/ico_tv_sat.gif" width="26" height="27"></div></td>
                      <td class="small"> Satelite Television</td>
                    </tr>
                    <tr>
                      <td align="center"><input type="checkbox" name="fac_pets" value="e" <?php if( strpos($room['facilities'], "e") > -1) echo "checked"; ?>></td>
                      <td align "center"><div align="center"><img src="images/icons/ico_pets.gif" width="26" height="27"></div></td>
                      <td class="small">No Pets</td>
                    </tr>
                    <tr>
                      <td align="center"><input type="checkbox" name="fac_park" value="c" <?php if( strpos($room['facilities'], "c") > -1) echo "checked"; ?>></td>
                      <td align="center"><img src="images/icons/ico_cover_park.gif" width="26" height="27"></td>
                      <td class="small">Covered Parking</td>
                    </tr>
                    <tr>
                      <td align="center"><input type="checkbox" name="fac_towels" value="o" <?php if( strpos($room['facilities'], "o") > -1) echo "checked"; ?>></td>
                      <td align="center"><img src="images/icons/ico_towels.gif" width="26" height="27"></td>
                      <td class="small">Towels Supplied</td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td align="right">&nbsp;</td>
                    </tr>
                    <tr> 
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td align="right"><label></label>
                      <input type="submit" name="Submit" value="Submit">
                        <input type="button" name="Cancel" value="Close Window" onClick="window.close();">
                        <input type="submit" name="delete" value="Delete Room"></td>
                    </tr>
                    <tr> 
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                  </table>
                </form>
            </table></td>
        <td bgcolor="#FFFFFF" align="right" background="images/admin_14.gif" style="background-position: right; background-repeat: repeat-y;"></td>
      </tr>
      <tr> 
        <td><img src="images/admin_21.gif" width="32" height="33"></td>
        <td bgcolor="#FFFFFF" background="images/admin_23.gif" style="background-position: bottom; background-repeat: repeat-x;"></td>
        <td><img src="images/admin_20.gif" width="32" height="33"></td>
      </tr>
    </table>
    
    </body>
    </html>

  • #6
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    I just ran through your code (more or less) and it works fine. Don't know what you're doing wrong. Unless for some reason you have $roomid set as a global variable inside dbGetRows(), and you're clearing it out in that function, then I don't know why you aren't getting your code to work.

    Are you sure you are running that code and not some older code?

  • #7
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,
    Thanks.. I have tried this on my live server as well and the same thing. Only think I can think of is that the value is being destroyed just before the Delete action takes place somehow.
    I have been so focused on this that did not discover that as soon as I add the delete record code then my Update script stops updating.

    I figured it had something to do with this line <?php if(isset($_POST['Submit']) && $result) echo "onLoad=\"window.close(); opener.location.reload(true);\""; ?>> which refreshes the opener location with ammended room name but only if there is no Delete action in the code. As soon as I remove the delete action then the update works. If I add an addional opener location line for the Delete action then same thing.. it just echos in the $var_dump and that's as far as I get..

    I am going to have to find another way around this and see if I can get the room id into a session and try and use that


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •