IF and Radio Buttons

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have the following code which connects to a  database and sets the  
value of counter to '0' and the date to be either the current date or a  
users own date. The database connects via an included script as this is  
a contribution for OSCommerce. Each section (the set date today and set  
date custom) works fine by itself (with the other half commented out)  
but I cant make it so the option is available via radio buttons, what am  
I doing wrong?

Thanks in advance,

P.S. This is the code I am using

//OS Commerce Counter Reset v0.15
//Author: Ben Allen

if ($submit) {
$flag="OK";   // This is the flag and we set it to OK
$msg="";        // Initializing the message to hold the error messages
//Set Query Variables
$query = "UPDATE counter SET counter = 0";
$today = date("Ymd");
$datetoday = "UPDATE counter SET startdate = $today";
//Set Date=Today
    if ($setdate="true") {
        $counterquery = mysql_query($query);
        $datequery = mysql_query($datetoday);
        echo "Counter Reset Succesfully";
//Set Date Custom
    if ($setdate="false") {
    //Edit Database:
        $customdate  = mktime(0, 0, 0, $month, $day, $year);
        $datecustom  = strftime("%Y%m%d", $customdate);
        $datecustomquery = "UPDATE counter SET startdate = $datecustom";
        $counterquery = mysql_query($query);
        $datecustomresult = mysql_query($datecustomquery);
        echo "Counter Reset Succesfully";
}else {
//Display Form
<form method="post" action="<?php echo $PHP_SELF?>">
<table width="260" border="0" align="center" height="90"> <tr  
align="center" valign="middle">
<td height="31"> <div align="right" class="content">
   <div align="left">
     <input name="setdate" type="radio" value="true">
   <div align="left">  </div></td></tr>
<tr align="center" valign="middle"> <td height="25"> <div  
align="right"><font color="FBC300"></font></div>
     <div align="left"><font color="FBC300">
       <input name="setdate" type="radio" value="false">
       <input name="day" type="text" id="day" size="2" maxlength="2">
       <input name="month" type="text" id="month" size="2"  
       <input name="year" type="text" id="year" size="4" maxlength="4">  

       (dd/mm/yyyy)      </div></td></tr> <tr align="center"  
valign="middle"> <td> <div align="center">
<input type="Submit" name="submit" value="Enter" class="button"> </div>
<div align="center"></div></td></tr> </table>
<font color="FBC300"> </font></form>
} // end if
require(DIR_WS_INCLUDES . 'application_bottom.php');

Re: IF and Radio Buttons

Quoted text here. Click to load it

== is the comparison operator, = is assignment. When you assign the string  
"true" to $setdate, of course it is true. Instead you need to compare  

if ($setdate=="true") {...
if ($setdate=="false") {...

"I am pro death penalty. That way people learn
their lesson for the next time." -- Britney Spears


Re: IF and Radio Buttons

Kimmo Laine wrote:
Quoted text here. Click to load it
Brilliant thanks, I knew it had to be some simple newbie mistake, thanks  
once again.


Site Timeline