Jump to content

Change DB query depending on radio button


fj1200

Recommended Posts

I have a similar question to Andy17 below.  I'm fairly new to javascript.  I have a number of SQL Server-driven php pages, but need a new set.  I have 2 different sql queries dependent on a radio button selection to determine if a job being looked at is running or pre-completed - the data comes out of different tables and will populate a drop-down list.  The form is the same whichever dataset is used.  Radio buttons work fine, but I can't get the value passed to a query.  Last part of the radio buttons:

}

if (chosen == "Running")

{

$JOBTYPE = 1

}

else {

$JOBTYPE = 0

}

}

 

The php-bit is:

 

 

If ($JOBTYPE == "0") $JOBQRY = ($jobselect0);

If ($JOBTYPE == "1") $JOBQRY = ($jobselect1);

 

while($nt=mssql_fetch_array($JOBQRY))

{

echo "<option value= $nt[JOB_NAME]"."$nt[JOB_DESCRIPTION]> $nt[JOB_DESCRIPTION]</option>";

}

echo "</select>";

 

Does javascript get upset if I use a $ in a variable?  If I don't php won't see it. 

just to be sure I need to ask you.

you do know that php is serverside(runs on the server computer) and javascript is clientside(runs in browser) right?

 

so this line in your code

If ($JOBTYPE == "0") $JOBQRY = ($jobselect0);

this will simply put $JOBTYPE in your javascript and not a usable value

(off topic but the If should be with undercaps if)

 

if you would write

If (<?php echo $JOBTYPE ?>== "0") <?php echo $JOBQRY ?> = (<?php echo$jobselect0 ?>);

 

that would be different

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.