|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
javascript and Php....(help needed)
hi,
I am having trouble getting this to work....here is the code below....it suppose to be a event driven code....the table(userProfile) is already created.....when you click the first radio button it pushes 1 into the table or else it pushes 2 into the table. But, for some reason the (if...else) structure is failing. Can you give me a pointer or modify my code so that I can understand it .............I know php is server side and javascript is client-side. --------------------------------------------------------------- <?php /* Connecting, selecting database */ $link = mysql_connect(localhost , team03 , team03) or die("Could not connect"); mysql_select_db(newsreader) or die("Could not select database"); ?> <form name = "form" method="POST"> <td><font class="smallblue">Select News Type:</td> // below is where the radio buttons are being created, the name have to be the same <td align=center width=10%><font class=medblue><input type=radio class=schedule name="R1" value="International News"><br>International News</td> <td align=center width=10%><font class=medblue><input type=radio class=schedule name="R1" value="Sports News"><br>Sports News</td> <script language = "javascript"> <!-- function save() { if (document.form.R1[0].checked) //test to see if the first radio button is clicked { alert("You have selected to receive International News on your PDA"); <?php mysql_query("DELETE FROM userProfile"); // I am doing this b/c I want to remove the row, so that it will always be 1 row and not grow $query = "INSERT INTO userProfile (choice) VALUES ('1')"; $result = mysql_query($query, $link); ?> } else { alert("You have selected to receive Sports News on your PDA"); <?php mysql_query("DELETE FROM userProfile"); // I am doing this b/c I want to remove the row, so that it will always be 1 row and not grow $query = "INSERT INTO userProfile (choice) VALUES ('2')"; $result = mysql_query($query, $link); ?> } <!--end script--> </script> <td class="mainftr" colspan="0" align="center"> <input type="hidden" name="pcount" value="1"> Click to save your setting: <input class="submit" type="submit" name="process_reminder" value="Save Preferences" onclick = "save()"> //javascript is call here when the Save button is clicked </form> </tr></table> <?php /* Closing connection */ mysql_close($link); ?> ______________________________________ Ok...I am going to bed now. Thanks aaa123 |
|
#2
|
||||
|
||||
|
This would be better posted in the PHP forum.
|
|
#3
|
||||
|
||||
|
In the future, avoid double-posting...
Read my answer here: http://forums.devarticles.com/showt...ted=1#post39240 |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > javascript and Php....(help needed) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|