#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Singapore
    Posts
    7
    Rep Power
    0
    I have this strange problem, and I know that for the experts out here it could be something trivial...


    // Initialize some variables -
    $web_style = "1";
    $background_colour = "White";
    $text_colour = "Black";
    .. blah
    .. blah
    .. blah
    $text_sub = $row->text_sub;
    $web_style = $row->web_style;
    $background_colour = $row->background_colour;
    $text_colour = $row->text_colour;
    .. blah
    .. blah
    <TD WIDTH=316 BGCOLOR="#CCCC99"><P><FONT SIZE="-2" FACE="Arial,Helvetica,Univers,Zurich BT">Background colour for the page</FONT></TD>
    <?php echo ("<TD WIDTH=317 BGCOLOR="#CCCC99"><P>
    <SELECT ID="FormsComboBox1" NAME="background_colour">
    <OPTION VALUE="White" SELECTED>$background_colour</OPTION>
    <OPTION VALUE="Aqua">Aqua</OPTION>
    <OPTION VALUE="Black">Black</OPTION>
    <OPTION VALUE="Blue">Blue</OPTION>
    <OPTION VALUE="Fuchsia">Fuchsia</OPTION>
    <OPTION VALUE="Gray">Gray</OPTION>
    <OPTION VALUE="Green">Green</OPTION>
    <OPTION VALUE="Lime">Lime</OPTION>
    <OPTION VALUE="Maroon">Maroon</OPTION>
    <OPTION VALUE="Navy">Navy</OPTION>
    <OPTION VALUE="Olive>Olive</OPTION>
    <OPTION VALUE="Orange">Orange</OPTION>
    <OPTION VALUE="Purple">Purple</OPTION>
    <OPTION VALUE="Red">Red</OPTION>
    <OPTION VALUE="Silver">Silver</OPTION>
    <OPTION VALUE="Yellow">Yellow</OPTION>
    <OPTION VALUE="White">White</OPTION>
    </SELECT>
    &nbsp;</TD>"); ?>

    A few issues heer:
    1) I listed 'White' again at the bottom as the form shows a blank line when the form is refreshed, even after I initialised the variables.

    2) The value of $background_colour did not return 'Black', but I confirmed the table-field has value 'Black' stored. The other 9 fields have their values moved in ok. For example, the value for $text_sub is correct. So when the data were retrieved, all fields relating to the combobox [ $web_stype, $background_colour and $text_colour ] did not appear right.

    Please help.


    ------------------
    -Living is about breathing-
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    <<
    $web_style = "1";
    $background_colour = "White";
    $text_colour = "Black";
    .. blah
    .. blah
    .. blah
    $text_sub = $row->text_sub;
    $web_style = $row->web_style;
    $background_colour = $row->background_colour;
    $text_colour = $row->text_colour;
    .. blah
    .. blah
    >>


    Hi,

    Why are you assigning values to the variable more than once?(ie,$background_colour = "White",$background_colour = $row->background_colour)?

    Can you tell us what is this "$row->background_colour"?.


    If you post that complete page code then only we can tell you what is gone wrong in your script.


    <<
    1) I listed 'White' again at the bottom as the form shows a blank line when the form is refreshed, even after I initialised the variables.
    >>


    I think '$background_colour'is not setting value properly.that is why it is giving that problem.





    ------------------
    SR -
    webshiju.com
    www.jobxyz.com-IT Career Portal
    ezipindia.com--WebStudio


    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Singapore
    Posts
    7
    Rep Power
    0
    Hi Shiju Rajan,

    Thank you for the help. I will try to put the whole thing up == it is long and I was trying not to fill up this page...

    The 1st time was to init the value of $background_colour to 'White' (default value). (He might not have created a home page yet).

    If he actually had created a home page, after the system makes a check to the database table for his record $Row, then I move the column value $row->background_colour to variable $background_colour.

    Later I will force this updated value ($background_colour) onto the form for the user to see his previous entry.

    Regards,
    Asian Help [I will see how I can post the whole list without moving a whole chunk of code here..]

    ------------------
    -Living is about breathing-
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Singapore
    Posts
    7
    Rep Power
    0
    Hi Shiju Rajan,

    While looking through, I found the problem. Here is the amended code. But I wonder how I can make it with less entry. How can I use the array to solve this problem? Or can it be done here? Mixing html and php is rather confusing to me, at times.

    <TR>
    <TD WIDTH=316 BGCOLOR="#CCCC99"><P><FONT SIZE="-2" FACE="Arial,Helvetica,Univers,Zurich BT">Background colour for the page</FONT></TD>
    <TD WIDTH=317 BGCOLOR="#CCCC99"><P>
    <SELECT ID="FormsComboBox1" NAME="background_colour">
    <OPTION VALUE="White" <?PHP if($background_colour=="White") echo "SELECTED"; ?>><?PHP echo "White" ?></option>
    <OPTION VALUE="Aqua" <?PHP if($background_colour=="Aqua") echo "SELECTED"; ?>><?PHP echo "Aqua" ?></option>
    <OPTION VALUE="Black" <?PHP if($background_colour=="Black") echo "SELECTED"; ?>><?PHP echo "Black" ?></option>
    <OPTION VALUE="Blue" <?PHP if($background_colour=="Blue") echo "SELECTED"; ?>><?PHP echo "Blue" ?></option>
    <OPTION VALUE="Fuchsia" <?PHP if($background_colour=="Fuchsia") echo "SELECTED"; ?>><?PHP echo "Fuchsia" ?></option>
    <OPTION VALUE="Gray" <?PHP if($background_colour=="Gray") echo "SELECTED"; ?>><?PHP echo "Gray" ?></option>
    <OPTION VALUE="Green" <?PHP if($background_colour=="Green") echo "SELECTED"; ?>><?PHP echo "Green" ?></option>
    <OPTION VALUE="Lime" <?PHP if($background_colour=="Lime") echo "SELECTED"; ?>><?PHP echo "Lime" ?></option>
    <OPTION VALUE="Maroon" <?PHP if($background_colour=="Maroon") echo "SELECTED"; ?>><?PHP echo "Maroon" ?></option>
    <OPTION VALUE="Navy" <?PHP if($background_colour=="Navy") echo "SELECTED"; ?>><?PHP echo "Navy" ?></option>
    <OPTION VALUE="Olive" <?PHP if($background_colour=="Olive") echo "SELECTED"; ?>><?PHP echo "Olive" ?></option>
    <OPTION VALUE="Orange" <?PHP if($background_colour=="Orange") echo "SELECTED"; ?>><?PHP echo "Orange" ?></option>
    <OPTION VALUE="Purple" <?PHP if($background_colour=="Purple") echo "SELECTED"; ?>><?PHP echo "Purple" ?></option>
    <OPTION VALUE="Red" <?PHP if($background_colour=="Red") echo "SELECTED"; ?>><?PHP echo "Red" ?></option>
    <OPTION VALUE="Silver" <?PHP if($background_colour=="Silver") echo "SELECTED"; ?>><?PHP echo "Silver" ?></option>
    <OPTION VALUE="Yellow" <?PHP if($background_colour=="Yellow") echo "SELECTED"; ?>><?PHP echo "Yellow" ?></option>
    </SELECT>
    &nbsp;</TD>
    </TR>

    Regards,
    AsianHelp

    ------------------
    -Living is about breathing-
  8. #5
  9. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    <<
    But I wonder how I can make it with less entry. How can I use the array to solve this problem?
    >>


    Hi AsianHelp,
    yea,you can optimize your code.
    See the following example.

    <?php
    $drop_down_values=array('White','Aqua','Black','Blue','Fuchsia','Gray','Green','Lime','Maroon','Navy ','Olive','Orange','Purple','Red','Silver','Yellow');

    //First create an array with all the items of drop down menu

    $drop_count=count($drop_down_values);
    //take the total count of dropdown items.

    echo "<SELECT ID="FormsComboBox1" NAME="background_colour">n";

    for($a=0;$a<$drop_count;$a++){
    //loop for populating selected value to the drop down.
    echo "<option value="$drop_down_values[$a]"";
    if ($drop_down_values[$a]==$background_colour){
    // selected item matching with drop down item
    //make it as selected.
    echo "selected";
    }
    echo ">$drop_down_values[$a]</option>n";
    }
    //close the drop down.
    echo "</select>n";
    ?>

    i hope this will help you in some way..

    Good Luck!!

    ------------------
    SR -
    webshiju.com
    www.jobxyz.com-IT Career Portal
    ezipindia.com--WebStudio


    "The fear of the LORD is the beginning of knowledge..."

    [This message has been edited by Shiju Rajan (edited August 17, 2000).]

Similar Threads

  1. Need advice designing a usage tracking database (MySQL)
    By Randolpho in forum Database Management
    Replies: 0
    Last Post: February 13th, 2004, 04:11 PM
  2. Newbie needing help sending data to mysql database
    By blackface in forum PHP Development
    Replies: 3
    Last Post: February 13th, 2004, 12:26 AM
  3. Replies: 3
    Last Post: February 11th, 2004, 08:30 AM
  4. Replies: 5
    Last Post: February 3rd, 2004, 01:59 PM
  5. MYSQL database
    By isheikh in forum MySQL Help
    Replies: 3
    Last Post: January 14th, 2004, 10:58 PM

IMN logo majestic logo threadwatch logo seochat tools logo