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
Solved

Update profile not updating for certain whole number values.

Posted on 2009-07-12
2
141 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
I use MySQL for many of my development projects in a Windows environment. To manage my databases (and perform queries) for years I used a tool called MySQL administrator.  This tool has since been replaced by MySQL Workbench. So I decided to m…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 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