Jump to content

List/Menu Box


j05hr

Recommended Posts

On an edit page when you want something to select what a user has previously selected from the database, how would you do this for a List/Menu box?  The only way I know how is

<?php echo $sel_subject['house_price']; ?>

 

This is what I have

 

<select name="propType" />
<?php echo $sel_subject['propType']; ?>
<option></option>
<option>House</option>
<option>Bungalow</option>
<option>Flat</option>
<option>Detached</option>
<option>Semi Detached</option>
<option>Terraced</option>
</select>

 

Also is it wrong to leave all the options on this page?

Link to comment
Share on other sites

I think you misunderstood the question.  For example if you had a list box with your age in it, when you got a year older, you would need to change it, how would you echo back from the database to have the answer you had from last time.  Like in a text box you just put <?php echo $sel_subject['house_price']; ?> in the value and it echos back what you wrote in the textbox in the database.  It doesn't work that simply with a listbox.

 

Sorry for the confusion and not explaining myself properly. 

Link to comment
Share on other sites

If your select box does not have an option for your "new" age, then you would have to add an additional option.

 

Example: John is 30. Your select box has 28,29,30 as options. John turns 31. There's nothing you can do with your select box unless you add an additional option for 31.

Link to comment
Share on other sites

No, it does have an option for your next birthday. I'll explain what I mean with a text box.  You write something in it, you want to change what you've written because you've made a spelling mistake.  What you've already is still there when you go to edit it because it's echoed back from the database (with that line of code I posted) how would you echo back the same result with a list box?

Link to comment
Share on other sites

Is this what you mean?

 

<select name="propType" />
<option selected><?php echo $sel_subject['propType']; ?></option>
<option></option>
<option>House</option>
<option>Bungalow</option>
<option>Flat</option>
<option>Detached</option>
<option>Semi Detached</option>
<option>Terraced</option>
</select>

 

<select name="bday" />
<option selected><?php echo $sel_subject['bday']; ?></option>
<option></option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
<option>32</option>
<option>33</option>
</select>

 

If its not I don't understand what you're trying to do o.o..

Link to comment
Share on other sites

Sorry for my ignorance if I am still not getting what you are asking. :)

 

List boxes (select boxes) do not work the same way as text inputs and textareas.  With inputs and textareas, you simply tell them what to display and thats it. Ex:

<input type="text" name="bla" value="Hello World!" /><br />
<textarea name="blabla">Hello World!</textarea>

 

With a list box, you have a predefined list of options that the user can choose from.

<select name="blablabla">
    <option>Hello World!</option>
    <option>Goodbye World!</option>
</select>

 

When a user pulls up an "edit info" form, you want whatever was saved in the database to be selected.  If the database contains "Goodbye World!" and you want that option to be selected, this is how you would do it.

<select name="blablabla">
    <option <?php echo $valueFromDb == 'Hello World!' ? 'selected="selected"' : ''; ?>>Hello World!</option>
    <option <?php echo $valueFromDb == 'Goodbye World!' ? 'selected="selected"' : ''; ?>>Goodbye World!</option>
</select>

 

A problem arises if you have a value in the database that does not have a corresponding option in the list box.  Solving it is out of scope from what you are asking I believe, but please let me know if this is not the case.

Link to comment
Share on other sites

Thanks, yeah that is what I meant and it works, it's what I tried but where I was going wrong was, not putting the PHP in an option tag.

 

I did it like,

 

<select name="propType" />
<?php echo $sel_subject['propType']; ?>
<option></option>
<option>House</option>
<option>Bungalow</option>
<option>Flat</option>
<option>Detached</option>
<option>Semi Detached</option>
<option>Terraced</option>
</select>

 

Makes sense why it wouldn't work now, thanks

Link to comment
Share on other sites

Sorry for my ignorance if I am still not getting what you are asking. :)

 

List boxes (select boxes) do not work the same way as text inputs and textareas.  With inputs and textareas, you simply tell them what to display and thats it. Ex:

<input type="text" name="bla" value="Hello World!" /><br />
<textarea name="blabla">Hello World!</textarea>

 

With a list box, you have a predefined list of options that the user can choose from.

<select name="blablabla">
    <option>Hello World!</option>
    <option>Goodbye World!</option>
</select>

 

When a user pulls up an "edit info" form, you want whatever was saved in the database to be selected.  If the database contains "Goodbye World!" and you want that option to be selected, this is how you would do it.

<select name="blablabla">
    <option <?php echo $valueFromDb == 'Hello World!' ? 'selected="selected"' : ''; ?>>Hello World!</option>
    <option <?php echo $valueFromDb == 'Goodbye World!' ? 'selected="selected"' : ''; ?>>Goodbye World!</option>
</select>

 

A problem arises if you have a value in the database that does not have a corresponding option in the list box.  Solving it is out of scope from what you are asking I believe, but please let me know if this is not the case.

 

hehe that works P: ..

Link to comment
Share on other sites

<?php require_once("includes/session.php"); ?>
<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php confirm_logged_in(); ?>
<?php
	if (intval($_GET['subj']) == 0) {
		redirect_to("content1.php");
	}
	if (isset($_POST['submit'])) {
		$errors = array();

		$required_fields = array('menu_name', 'position', 'visible', 'content', 'house_price', 'bedrooms', 'propType');
		foreach($required_fields as $fieldname) {
			if (!isset($_POST[$fieldname]) || (empty($_POST[$fieldname]) && $_POST[$fieldname] != 0)) { 
				$errors[] = $fieldname; 
			}
		}
		$fields_with_lengths = array('menu_name' => 30);
		foreach($fields_with_lengths as $fieldname => $maxlength ) {
			if (strlen(trim(mysql_prep($_POST[$fieldname]))) > $maxlength) { $errors[] = $fieldname; }
		}

		if (empty($errors)) {
			// Perform Update
			$id = mysql_prep($_GET['subj']);
			$menu_name = mysql_prep($_POST['menu_name']);
			$position = mysql_prep($_POST['position']);
			$visible = mysql_prep($_POST['visible']);
			$content = mysql_prep($_POST['content']);
			$house_price = mysql_prep($_POST['house_price']);
			$bedrooms = mysql_prep($_POST['bedrooms']);
			$propType = mysql_prep($_POST['propType']);

			$query = "UPDATE subjects SET 
						menu_name = '{$menu_name}', 
						position = {$position}, 
						visible = {$visible},
						content = '{$content}',
						house_price = '{$house_price}',
						bedrooms = {$bedrooms},
						propType = {$propType}
					WHERE id = {$id}";
			$result = mysql_query($query, $connection);
			if (mysql_affected_rows() == 1) {
				// Success
				$message = "The subject was successfully updated.";
			} else {
				// Failed
				$message = "The subject update failed.";
				$message .= "<br />". mysql_error();
			}

		} else {
			// Errors occurred
			$message = "There were " . count($errors) . " errors in the form.";
		}




	} // end: if (isset($_POST['submit']))
?>
<?php find_selected_page();?>
<?php include("includes/header.php"); ?>
<div id="content">
	<h2> Buying Edit Page</h2>
	<br />
	<h5>Edit Subject: <?php echo $sel_subject ['menu_name']; ?></h5>
		<?php if (!empty($message)) {
			echo "<p class=\"messge\">" . $message . "</p>";
		} ?>
		<?php
		// output a list of the fields that had errors
		if (!empty($errors)) {
			echo "<p class=\"errors\">";
			echo "Please review the following fields:<br />";
			foreach($errors as $error) {
				echo " - " . $error . "<br />";
			}
			echo "</p>";
		}
		?>
		<form action="edit_subject.php?subj=<?php echo urlencode($sel_subject['id']);?>" method="post">
			<p>Subject name: 
				<input type="text" name="menu_name" value="<?php echo $sel_subject['menu_name']; ?>" id="menu_name" />
			</p>
			<p>House Price: 
				<input type="text" name="house_price" value="<?php echo $sel_subject['house_price']; ?>" id="house_price" />
			</p>
			<p>Bedrooms: 
				<select name="bedrooms" />
					<option selected><?php echo $sel_subject['bedrooms']; ?></option>
					<option>1</option>
					<option>2</option>
					<option>3</option>
					<option>4</option>
					<option>5+</option>
				</select>
			</p>
			<p>Type of Property: 
				<select name="propType" />
					<option><?php echo $sel_subject['propType']; ?></option>
					<option>House</option>
					<option>Bungalow</option>
					<option>Flat</option>
					<option>Detached</option>
					<option>Semi Detached</option>
					<option>Terraced</option>
				</select>
			</p>
			<p>Edit content:
				<textarea name="content" rows="5" cols="70"><?php echo $sel_subject['content']; ?> </textarea>
				</p>
			<p>Position: 
				<select name="position">
					<?php
						$subject_set = get_all_subjects();
						$subject_count = mysql_num_rows($subject_set);
						// $subject_count + 1 b/c we are adding a subject
						for($count=1; $count <= $subject_count+1; $count++) {
							echo "<option value=\"{$count}\"";
							if ($sel_subject['position'] == $count) {
								echo " selected";
							} 
							echo ">{$count}</option>";
						}
					?>
				</select>
			</p>
			<p>Visible: 
				<input type="radio" name="visible" value="0"<?php 
				if ($sel_subject['visible'] == 0) { echo " checked"; } 
				?> /> No
				 
				<input type="radio" name="visible" value="1"<?php 
				if ($sel_subject['visible'] == 1) { echo " checked"; } 
				?> /> Yes
			</p>
			<input type="submit" name="submit" value="Update Subject" />
			</p>

			<h5 id="link"><a href="delete_subject.php?subj=<?php echo urlencode($sel_subject['id']); ?>" onclick="return confirm('Are you sure?');">Delete Subject</a></h5>
		</form>
		<br />
		<h5 id="link"><a href="edit_page.php?page=<?php echo urlencode($sel_subject['id']); ?>">Edit Page</a></h5>
		<h5 id="link"><a href="content1.php">Cancel</a></h5>
		<h5 id="link"><a href="new_page.php?subj=<?php echo $sel_subject['id']; ?>">+ Add a new page to this subject</a></h5>
<?php


?>
</div>

<?php require("includes/footer.php"); ?>

 

My header where the main html is..

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Estate Agents</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="stylenew.css" />
<!--[if lte IE 6]>
<style type="text/css">
#page-wrap {display:inline-block;}
.featured {padding: 0px;}
</style>
<![endif]-->
<!--[if lte IE 7]>
<style type="text/css">
#page-wrap {display:inline-block;}
.featured {padding-bottom: 10px;}
</style>
<![endif]-->


</head>
<body>
<div id="page-wrap">
<h1>Estate Agent</h1>
<div id="navigation">
<ul>
<li class="home"><a href="index.php">Home</a></li>
<li class="buying"><a href="buying.php">Buying</a></li>
<li class="selling"><a href="selling.php">Selling</a></li>
<li class="renting"><a href="renting.php">Renting</a></li>
<li class="letting"><a href="letting.php">Letting</a></li>
<li class="contact"><a href="contact.php">Contact</a></li>
</ul>
</div>
<div id="sidebar">
<h3 class="sidebar-text"></h3>
<div id="menu">
<ul>
<li class="home"><a href="index.php">Home</a></li>
<li class="buy"><a href="buying.php">Buying</a></li>
<li class="sell"><a href="selling.php">Selling</a></li>
<li class="renting"><a href="renting.php">Renting</a></li>
<li class="newhomes"><a href="newhomes.php">New Homes</a></li>
<li class="contact"><a href="contact.php">Contact Us</a></li>
<li class="about"><a href="about.php">About Us</a></li>
<li class="location"><a href="location.php">Locations</a></li>
<li class="why"><a href="whyus.php">Why Use Us</a></li>
<li class="mailing"><a href="mailinglist.php">Mailing List</a></li>
</ul>
<div class="featured">
<h3 class="sidebar-text1"></h3>
</div>
<div class="featured-bg">
<a href="home2.php"><img src="pictures/feature-house.jpg" alt="propoftheweek" /></a>
<p>Price: £1.395 000 </p>
<p>5 Bedrooms </p>
<p>Indoor Swimming Pool</p>
<p>Tennis Court</p>
<p>Gym</p>
<p>Double Garage </p>
</div>
</div>
</div>
<div id="flash">
<object type="application/x-shockwave-flash"
data="transition.swf"
width="695" height="215">
<param name="movie" value="transition.swf" />
<param name="quality" value="high"/>
</object>
</div>

Link to comment
Share on other sites

Looking at this portion specifically:

            <p>Bedrooms:
               <select name="bedrooms" />
                  <option selected><?php echo $sel_subject['bedrooms']; ?></option>
                  <option>1</option>
                  <option>2</option>
                  <option>3</option>
                  <option>4</option>
                  <option>5+</option>
               </select>
            </p>
            <p>Type of Property:
               <select name="propType" />
                  <option><?php echo $sel_subject['propType']; ?></option>
                  <option>House</option>
                  <option>Bungalow</option>
                  <option>Flat</option>
                  <option>Detached</option>
                  <option>Semi Detached</option>
                  <option>Terraced</option>
               </select>
            </p>

Make it look like the code I posted last.

Link to comment
Share on other sites

I copy and pasted what you sent last time, is that wrong?

 

Also for those lists, what should the type be in the database as it's saying Unknown column 'Bungalow' in 'field list'

 

And You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' propType = 3 WHERE id = 53' at line 7 when I try to use 5+ bedrooms (assuming what I'm using doesn't like the plus sign as 1,2,3 and 4 bedrooms work but 5+ and none of the words work on type of property

Link to comment
Share on other sites

It doesn't work but I didn't think you knew what I meant.

 

Here is the code I've used

 

<select name="bedrooms"/>
    <option <?php echo $sel_subject == '1!' ? 'selected="selected"' : ''; ?>>1</option>
    <option <?php echo $sel_subject == '2!' ? 'selected="selected"' : ''; ?>>2</option>
    <option <?php echo $sel_subject == '3!' ? 'selected="selected"' : ''; ?>>3</option>
    <option <?php echo $sel_subject == '4!' ? 'selected="selected"' : ''; ?>>4</option>
    <option <?php echo $sel_subject == '5+!' ? 'selected="selected"' : ''; ?>>5+</option>
</select>

 

Say I've selected 2 and click submit, it saves it which is fine, if I came back to edit it.  I want it to say 2 (the last thing you saved it as) but it just says the first option.

 

Link to comment
Share on other sites

<?php require_once("includes/session.php"); ?>
<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php confirm_logged_in(); ?>
<?php
	if (intval($_GET['subj']) == 0) {
		redirect_to("content1.php");
	}
	if (isset($_POST['submit'])) {
		$errors = array();

		$required_fields = array('menu_name', 'position', 'visible', 'content', 'house_price', 'bedrooms', 'propType');
		foreach($required_fields as $fieldname) {
			if (!isset($_POST[$fieldname]) || (empty($_POST[$fieldname]) && $_POST[$fieldname] != 0)) { 
				$errors[] = $fieldname; 
			}
		}
		$fields_with_lengths = array('menu_name' => 30);
		foreach($fields_with_lengths as $fieldname => $maxlength ) {
			if (strlen(trim(mysql_prep($_POST[$fieldname]))) > $maxlength) { $errors[] = $fieldname; }
		}

		if (empty($errors)) {
			// Perform Update
			$id = mysql_prep($_GET['subj']);
			$menu_name = mysql_prep($_POST['menu_name']);
			$position = mysql_prep($_POST['position']);
			$visible = mysql_prep($_POST['visible']);
			$content = mysql_prep($_POST['content']);
			$house_price = mysql_prep($_POST['house_price']);
			$bedrooms = mysql_prep($_POST['bedrooms']);
			$propType = mysql_prep($_POST['propType']);

			$query = "UPDATE subjects SET 
						menu_name = '{$menu_name}', 
						position = {$position}, 
						visible = {$visible},
						content = '{$content}',
						house_price = '{$house_price}',
						bedrooms = '{$bedrooms}',
						propType = '{$propType}'
					WHERE id = {$id}";
			$result = mysql_query($query, $connection);
			if (mysql_affected_rows() == 1) {
				// Success
				$message = "The subject was successfully updated.";
			} else {
				// Failed
				$message = "The subject update failed.";
				$message .= "<br />". mysql_error();
			}

		} else {
			// Errors occurred
			$message = "There were " . count($errors) . " errors in the form.";
		}




	} // end: if (isset($_POST['submit']))
?>
<?php find_selected_page();?>
<?php include("includes/header.php"); ?>
<div id="content">
	<h2> Buying Edit Page</h2>
	<br />
	<h5>Edit Subject: <?php echo $sel_subject ['menu_name']; ?></h5>
		<?php if (!empty($message)) {
			echo "<p class=\"messge\">" . $message . "</p>";
		} ?>
		<?php
		// output a list of the fields that had errors
		if (!empty($errors)) {
			echo "<p class=\"errors\">";
			echo "Please review the following fields:<br />";
			foreach($errors as $error) {
				echo " - " . $error . "<br />";
			}
			echo "</p>";
		}
		?>
		<form action="edit_subject.php?subj=<?php echo urlencode($sel_subject['id']);?>" method="post">
			<p>Subject name: 
				<input type="text" name="menu_name" value="<?php echo $sel_subject['menu_name']; ?>" id="menu_name" />
			</p>
			<p>House Price: 
				<input type="text" name="house_price" value="<?php echo $sel_subject['house_price']; ?>" id="house_price" />
			</p>
			<p>Bedrooms: 

					<select name="bedrooms"/>
    <option <?php echo $sel_subject['bedrooms'] == '1!' ? 'selected="selected"' : ''; ?>>1</option>
    <option <?php echo $sel_subject['bedrooms'] == '2!' ? 'selected="selected"' : ''; ?>>2</option>
<option <?php echo $sel_subject['bedrooms'] == '3!' ? 'selected="selected"' : ''; ?>>3</option>
<option <?php echo $sel_subject['bedrooms'] == '4!' ? 'selected="selected"' : ''; ?>>4</option>
<option <?php echo $sel_subject['bedrooms'] == '5+!' ? 'selected="selected"' : ''; ?>>5+</option>
</select>

			</p>
			<p>Type of Property: 
				<select name="propType" />
					<option <?php echo $sel_subject == 'House!' ? 'House"' : ''; ?>>House</option>
					<option <?php echo $sel_subject == 'Bungalow!' ? 'selected="selected"' : ''; ?>>Bungalow</option>
					<option <?php echo $sel_subject == 'Flat!' ? 'selected="selected"' : ''; ?>>Flat</option>
					<option <?php echo $sel_subject == 'Detatched!' ? 'selected="selected"' : ''; ?>>Detatched</option>
					<option <?php echo $sel_subject == 'Semi_detached!' ? 'selected="selected"' : ''; ?>>Semi_Detached</option>
					<option <?php echo $sel_subject == 'Terraced!' ? 'selected="selected"' : ''; ?>>Terraced</option>
				</select>
			</p>
			<p>Edit content:
				<textarea name="content" rows="5" cols="70"><?php echo $sel_subject['content']; ?> </textarea>
				</p>
			<p>Position: 
				<select name="position">
					<?php
						$subject_set = get_all_subjects();
						$subject_count = mysql_num_rows($subject_set);
						// $subject_count + 1 b/c we are adding a subject
						for($count=1; $count <= $subject_count+1; $count++) {
							echo "<option value=\"{$count}\"";
							if ($sel_subject['position'] == $count) {
								echo " selected";
							} 
							echo ">{$count}</option>";
						}
					?>
				</select>
			</p>
			<p>Visible: 
				<input type="radio" name="visible" value="0"<?php 
				if ($sel_subject['visible'] == 0) { echo " checked"; } 
				?> /> No
				 
				<input type="radio" name="visible" value="1"<?php 
				if ($sel_subject['visible'] == 1) { echo " checked"; } 
				?> /> Yes
			</p>
			<input type="submit" name="submit" value="Update Subject" />
			</p>

			<h5 id="link"><a href="delete_subject.php?subj=<?php echo urlencode($sel_subject['id']); ?>" onclick="return confirm('Are you sure?');">Delete Subject</a></h5>
		</form>
		<br />
		<h5 id="link"><a href="edit_page.php?page=<?php echo urlencode($sel_subject['id']); ?>">Edit Page</a></h5>
		<h5 id="link"><a href="content1.php">Cancel</a></h5>
		<h5 id="link"><a href="new_page.php?subj=<?php echo $sel_subject['id']; ?>">+ Add a new page to this subject</a></h5>
<?php


?>
</div>

<?php require("includes/footer.php"); ?>
[code]

Link to comment
Share on other sites

All I touched was the select boxes.

<?php require_once("includes/session.php"); ?>
<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php confirm_logged_in(); ?>
<?php
      if (intval($_GET['subj']) == 0) {
         redirect_to("content1.php");
      }
      if (isset($_POST['submit'])) {
         $errors = array();

         $required_fields = array('menu_name', 'position', 'visible', 'content', 'house_price', 'bedrooms', 'propType');
         foreach($required_fields as $fieldname) {
            if (!isset($_POST[$fieldname]) || (empty($_POST[$fieldname]) && $_POST[$fieldname] != 0)) { 
               $errors[] = $fieldname; 
            }
         }
         $fields_with_lengths = array('menu_name' => 30);
         foreach($fields_with_lengths as $fieldname => $maxlength ) {
            if (strlen(trim(mysql_prep($_POST[$fieldname]))) > $maxlength) { $errors[] = $fieldname; }
         }
         
         if (empty($errors)) {
            // Perform Update
            $id = mysql_prep($_GET['subj']);
            $menu_name = mysql_prep($_POST['menu_name']);
            $position = mysql_prep($_POST['position']);
            $visible = mysql_prep($_POST['visible']);
            $content = mysql_prep($_POST['content']);
            $house_price = mysql_prep($_POST['house_price']);
            $bedrooms = mysql_prep($_POST['bedrooms']);
            $propType = mysql_prep($_POST['propType']);
            
            $query = "UPDATE subjects SET 
                     menu_name = '{$menu_name}', 
                     position = {$position}, 
                     visible = {$visible},
                     content = '{$content}',
                     house_price = '{$house_price}',
                     bedrooms = '{$bedrooms}',
                     propType = '{$propType}'
                  WHERE id = {$id}";
            $result = mysql_query($query, $connection);
            if (mysql_affected_rows() == 1) {
               // Success
               $message = "The subject was successfully updated.";
            } else {
               // Failed
               $message = "The subject update failed.";
               $message .= "<br />". mysql_error();
            }
            
         } else {
            // Errors occurred
            $message = "There were " . count($errors) . " errors in the form.";
         }
         
         
         
         
      } // end: if (isset($_POST['submit']))
?>
<?php find_selected_page();?>
<?php include("includes/header.php"); ?>
<div id="content">
      <h2> Buying Edit Page</h2>
      <br />
      <h5>Edit Subject: <?php echo $sel_subject ['menu_name']; ?></h5>
         <?php if (!empty($message)) {
            echo "<p class=\"messge\">" . $message . "</p>";
         } ?>
         <?php
         // output a list of the fields that had errors
         if (!empty($errors)) {
            echo "<p class=\"errors\">";
            echo "Please review the following fields:<br />";
            foreach($errors as $error) {
               echo " - " . $error . "<br />";
            }
            echo "</p>";
         }
         ?>
         <form action="edit_subject.php?subj=<?php echo urlencode($sel_subject['id']);?>" method="post">
            <p>Subject name:
               <input type="text" name="menu_name" value="<?php echo $sel_subject['menu_name']; ?>" id="menu_name" />
            </p>
            <p>House Price:
               <input type="text" name="house_price" value="<?php echo $sel_subject['house_price']; ?>" id="house_price" />
            </p>
            <p>Bedrooms:
               <select name="bedrooms"/>
                  <option <?php echo $sel_subject['bedrooms'] == '1' ? 'selected="selected"' : ''; ?>>1</option>
                  <option <?php echo $sel_subject['bedrooms'] == '2' ? 'selected="selected"' : ''; ?>>2</option>
                  <option <?php echo $sel_subject['bedrooms'] == '3' ? 'selected="selected"' : ''; ?>>3</option>
                  <option <?php echo $sel_subject['bedrooms'] == '4' ? 'selected="selected"' : ''; ?>>4</option>
                  <option <?php echo $sel_subject['bedrooms'] == '5+' ? 'selected="selected"' : ''; ?>>5+</option>
               </select>
            </p>
            <p>Type of Property:
               <select name="propType" />
                  <option <?php echo $sel_subject['propType'] == 'House' ? 'House"' : ''; ?>>House</option>
                  <option <?php echo $sel_subject['propType'] == 'Bungalow' ? 'selected="selected"' : ''; ?>>Bungalow</option>
                  <option <?php echo $sel_subject['propType'] == 'Flat' ? 'selected="selected"' : ''; ?>>Flat</option>
                  <option <?php echo $sel_subject['propType'] == 'Detatched' ? 'selected="selected"' : ''; ?>>Detatched</option>
                  <option <?php echo $sel_subject['propType'] == 'Semi_Detached' ? 'selected="selected"' : ''; ?>>Semi_Detached</option>
                  <option <?php echo $sel_subject['propType'] == 'Terraced' ? 'selected="selected"' : ''; ?>>Terraced</option>
               </select>
            </p>
            <p>Edit content:
               <textarea name="content" rows="5" cols="70"><?php echo $sel_subject['content']; ?> </textarea>
               </p>
            <p>Position:
               <select name="position">
                  <?php
                     $subject_set = get_all_subjects();
                     $subject_count = mysql_num_rows($subject_set);
                     // $subject_count + 1 b/c we are adding a subject
                     for($count=1; $count <= $subject_count+1; $count++) {
                        echo "<option value=\"{$count}\"";
                        if ($sel_subject['position'] == $count) {
                           echo " selected";
                        } 
                        echo ">{$count}</option>";
                     }
                  ?>
               </select>
            </p>
            <p>Visible:
               <input type="radio" name="visible" value="0"<?php 
               if ($sel_subject['visible'] == 0) { echo " checked"; } 
               ?> /> No
                
               <input type="radio" name="visible" value="1"<?php 
               if ($sel_subject['visible'] == 1) { echo " checked"; } 
               ?> /> Yes
            </p>
            <input type="submit" name="submit" value="Update Subject" />
            </p>
            
            <h5 id="link"><a href="delete_subject.php?subj=<?php echo urlencode($sel_subject['id']); ?>" onclick="return confirm('Are you sure?');">Delete Subject</a></h5>
         </form>
         <br />
         <h5 id="link"><a href="edit_page.php?page=<?php echo urlencode($sel_subject['id']); ?>">Edit Page</a></h5>
         <h5 id="link"><a href="content1.php">Cancel</a></h5>
         <h5 id="link"><a href="new_page.php?subj=<?php echo $sel_subject['id']; ?>">+ Add a new page to this subject</a></h5>
</div>

<?php require("includes/footer.php"); ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.