squiblo Posted August 29, 2009 Share Posted August 29, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/172365-solved-why-will-this-not-work/ Share on other sites More sharing options...
squiblo Posted August 29, 2009 Author Share Posted August 29, 2009 i found my problem, the name for the button and the options were the same Quote Link to comment https://forums.phpfreaks.com/topic/172365-solved-why-will-this-not-work/#findComment-908816 Share on other sites More sharing options...
roopurt18 Posted August 29, 2009 Share Posted August 29, 2009 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; Quote Link to comment https://forums.phpfreaks.com/topic/172365-solved-why-will-this-not-work/#findComment-908818 Share on other sites More sharing options...
Gayner Posted August 29, 2009 Share Posted August 29, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/172365-solved-why-will-this-not-work/#findComment-908823 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.