Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Update profile not updating for certain whole number values.

Posted on 2009-07-12
2
Medium Priority
?
146 Views
Last Modified: 2012-05-07
This is a continuation on from question I.D. 24546173

Basically I have a page within my website which allows members of the site to update their profile. The profiles are drawn from a MySQL database. There was a field (Teaching Experience)
which was not updating correctly, and on the update page, was not displaying the informaion which was in the database.

However thanks to Almer and Ray on this site (points still to be awarded as question I.D. 24546173 not closed yet) I'm able to get the page working so that it correctly displays the value in the database on the update page for some of the values - but not all, hence why I'm asking another new question.

Basically, the page updates correctly for values 0.0, 0.2, 0.5, 0.7, 1.5, 2.5 but not for whole values 1.0, 2.0, 3.0 , 4.0, 5.0, 6.0, 7.0 etc.

I have no idea why.

I have re-opened this question as the last one was no longer getting a response and I am hoping to resolve this issue before the working week begins.

Thanks


<?php     echo "<pre>"; print_r( $row_rsupdate['teachingexperience']); echo "</pre>";    ?>
 
								<select name="teachingexperience">
                                  <option value="0" <?php if ($row_rsupdate['teachingexperience'] == 0) {echo "selected=\"selected\"";} ?>>No Experience</option>
                                  <option value="0.2" <?php if (!(strcmp(0.2, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>Just a couple of months</option>
                                  <option value="0.5" <?php if (!(strcmp(0.5, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>About 6 months</option>
                                  <option value="0.7" <?php if (!(strcmp(0.7, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>About 9 months</option>
                                  <option value="1.0" <?php if (!(strcmp(1, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>1 year</option>
                                  <option value="1.5" <?php if (!(strcmp(1.5, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>1 and half years</option>
                                  <option value="2.0" <?php if (!(strcmp(2.0, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>2 years</option>
                                  <option value="2.5" <?php if (!(strcmp(2.5, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>2 and half years</option>
                                   <option value="3.0" <?php if (!(strcmp(3.0, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>3 years</option>
                                  <option value="4.0" <?php if (!(strcmp(4.0, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>4 years </option>
                                  <option value="5.0" <?php if (!(strcmp(5.0, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>5 years</option>
                                  <option value="6.0" <?php if (!(strcmp(6.0, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>6 years</option>
                                  <option value="7.0" <?php if (!(strcmp(7.0, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>7 years</option>
                                  <option value="8.0" <?php if (!(strcmp(8.0, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>8 years</option>
                                  <option value="9.0" <?php if (!(strcmp(9.0, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>9 years</option>
                                  <option value="10.0" <?php if (!(strcmp(10.0, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>10 years</option>
                                  <option value="11.0" <?php if (!(strcmp(11.0, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>11 years</option>
                                  <option value="12.0" <?php if (!(strcmp(12.0, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>12 years</option>
                                  <option value="13.0" <?php if (!(strcmp(13.0, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>13 years</option>
                                  <option value="14.0" <?php if (!(strcmp(14.0, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>14 years</option>
                                  <option value="15.0" <?php if (!(strcmp(15.0, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>15 years</option>
                                  <option value="16.0" <?php if (!(strcmp(16.0, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>16 years</option>
                                  <option value="17.0" <?php if (!(strcmp(17.0, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>17 years</option>
                                  <option value="18.0" <?php if (!(strcmp(18.0, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>18 years</option>
                                  <option value="19.0" <?php if (!(strcmp(19.0, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>19 years</option>
                                  <option value="20.0" <?php if (!(strcmp(20.0, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>20 years</option>
                                  <option value="21.0" <?php if (!(strcmp(21.0, $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>more than 20 !</option>
                                </select>

Open in new window

0
Comment
Question by:ayounis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 51

Accepted Solution

by:
Steve Bink earned 500 total points
ID: 24849464
One possibility is that your call to strcmp() is passing a number value.  PHP will simplify from 21.0 to 21, for example.  Try specifying the strcmp() parameters as strings:


<option value="21.0" <?php if (!(strcmp("21.0", $row_rsupdate['teachingexperience']))) {echo "selected=\"selected\"";} ?>>more than 20 !</option>

Open in new window

0
 

Author Comment

by:ayounis
ID: 24919706
Yep - that worked.

Thanks alot routinet and sorry for the delay, in responding.

Many thanks.
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

610 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