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. 

Link to comment
Share on other sites

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

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.