Solved

Update profile not updating for certain whole number values.

Posted on 2009-07-12
2
139 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
2 Comments
 
LVL 50

Accepted Solution

by:
Steve Bink earned 125 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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MySQL 11 79
How do i connect MySQL on Visual Studio 3 54
Duplicating MySQL Table columns 5 31
How many transactions can mysql handle? 3 18
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

929 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now