[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Values does not retains

Posted on 2012-08-19
2
Medium Priority
?
411 Views
Last Modified: 2012-08-20
Hello Experts,

User selects the option and then it hit the submit button the values it has selected gets to default zero whereas the selected values get updated into database.

please find below code for this...
....
<td align="center"><select name="ss1">
		<option value="0">0</option>
		<option value="5">5</option>
		<option value="15">15</option>
		<option value="25">25</option>
		</select>
		<?php
		$notify = "";
		if ($usr_name == 'XSP') {
			$usrid = '2';
		}
		if(isset($_POST['ss1'])){ $notify = $_POST['ss1']; 
		$query = "UPDATE usr_k SET usrslfscre='$notify' WHERE id='1' AND pmid='$usrid'";
		mysql_query($query);
		//print_r($_POST['ss1']); -
		}
			}
        ?>

Open in new window


Thanks in advance,
Shail
0
Comment
Question by:ShaileshShinde
2 Comments
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 200 total points
ID: 38310648
If you are posting to the same page, it will still reload the page with the default values.  That is normal operation and you have done nothing to change that.  If you want to 'retain' the selected value, you must use the POSTed value of 'ssl' to change one of the <option> to selected="selected".

....
<td align="center">
	<?php
	$notify = "";
	if ($usr_name == 'XSP') {
		$usrid = '2';
		}
	if(isset($_POST['ss1'])) { 
                $notify = $_POST['ss1']; 
		$query = "UPDATE usr_k SET usrslfscre='$notify' WHERE id='1' AND pmid='$usrid'";
		mysql_query($query);
		//print_r($_POST['ss1']); -
		}
	}
     ?>
<select name="ss1">
<option value="0"<?php if ($notify == '0') echo ' selected="selected"';?>>0</option>
<option value="5"<?php if ($notify == '5') echo ' selected="selected"';?>>5</option>
<option value="15"<?php if ($notify == '15') echo ' selected="selected"';?>>15</option>
<option value="25"<?php if ($notify == '25') echo ' selected="selected"';?>>25</option>
</select>
 

Open in new window

0
 
LVL 1

Author Closing Comment

by:ShaileshShinde
ID: 38310934
Thanks
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we’ll look at how to deploy ProxySQL.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month20 days, 12 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question