Jump to content

[SOLVED] why will this not work?


squiblo

Recommended Posts

ive messed about with this code for ages now but i cant get it to work, can anyone see the problem? there are no errors. The problem is that, it is always echoing from the database but when i change it in the form, it still echoes the same things from the database

 

<style>
table.pagecontent {
background-color: <?php if (!isset($_GET['bgcolor'])){
?>
<?php

$_SESSION['myusername'];

$connect = mysql_connect("***","***","***") or die ("Couldn't connect");
mysql_select_db("***") or die ("Couldn't find db");

$username = isset($_SESSION['myusername']) ? $_SESSION['myusername'] : 'default_value';

$query = mysql_query("SELECT * FROM members WHERE username='$username'");
if (mysql_num_rows($query)==0){
   die;
}else{
   $row = mysql_fetch_assoc($query);
   $location = $row['bgcolor'];
   if($location == ""){
      echo "";
   }else{
      echo $location;
   }
}
?>
<?php
}
else
echo ($_GET['bgcolor']);
?>
}
</style>

<form name="bgcolor" method="GET" action="">
Background color:<br>
<select name="bgcolor"><option selected></option>
<option style="background-color:#F0F8FF; color: #000000;">AliceBlue</option>
<option style="background-color:#FAEBD7; color: #000000;">AntiqueWhite</option>
<option style="background-color:#00FFFF; color: #000000;">Aqua</option>
<input type="submit" name="bgcolor" value="Change"></form>
</form>

Link to comment
Share on other sites

I'm too tired to say much that will help you with your actual problem, but I will point out that:

 

   if($location == ""){
      echo "";
   }else{
      echo $location;
   }

 

is equivalent to:

 

echo $location;

edit: nvm ya ur right, else if LOL

 

:)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.