|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Populating from Radio Button
hi all,
Thank you for you are always there to help me in tough situations. Now again i have a problem. I am populating a radio button from database. On clicking that radio button, i need the related row of that field in radio button to be retrieved from the data base I have written a code, but its retrieving only blank values or empty values. Heres my code Project1.php(this script i am using to populate the radiobutton) <html> <body> <?php include ("DbConnection.php")?> <? $sql = "select distinct NetProcess from tblEventLog order by tblEventLog.NetProcess"; <form method="post" action="Project2.php"> $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $NP=$row["NetProcess"]; echo "<input type=\"radio\" name=\"N\" value=\"N\"> $NP"; echo "<br>"; } mysql_query($result); ?> <input name="step" type="hidden" value="1" /> <input name="submit" type="submit" value="add" /> </form> </body> </html> Project2.php(This script i am using for when clicking the radio button for corresponding NetProcess(a particular field) its respective all other row values or column values shld be retrieved) <? include("DbConnection.php"); ?> <h2>View '$date' Alarms!!</h2> <?php $N = $_POST['N']; $query = "SELECT * FROM tblEventLog WHERE NetProcess = '".$N."' "; $result = mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <table border="1" cellspacing="2" cellpadding="2"> <tr> <th><font face="Arial, Helvetica, sans-serif">NetProcess</font></th> <th><font face="Arial, Helvetica, sans-serif">Node</font></th> <th><font face="Arial, Helvetica, sans-serif">Unit</font></th> <th><font face="Arial, Helvetica, sans-serif">Class</font></th> <th><font face="Arial, Helvetica, sans-serif">Date</font></th> <th><font face="Arial, Helvetica, sans-serif">Start</font></th> <th><font face="Arial, Helvetica, sans-serif">End</font></th> <th><font face="Arial, Helvetica, sans-serif">Frequency</font></th> <th><font face="Arial, Helvetica, sans-serif">Service</font></th> <th><font face="Arial, Helvetica, sans-serif">Severity</font></th> <th><font face="Arial, Helvetica, sans-serif">Direction</font></th> <th><font face="Arial, Helvetica, sans-serif">Location</font></th> <th><font face="Arial, Helvetica, sans-serif">Atype</font></th> <th><font face="Arial, Helvetica, sans-serif">CompanyID</font></th> <th><font face="Arial, Helvetica, sans-serif">CustomerID</font></th> <th><font face="Arial, Helvetica, sans-serif">Description</font></th> </tr> <?$i=0; while ($i < $num) { $NetProcess=mysql_result($result,$i,"NetProcess"); $Node=mysql_result($result,$i,"Node"); $Unit=mysql_result($result,$i,"Unit"); $Class=mysql_result($result,$i,"Class"); $Date=mysql_result($result,$i,"Date"); $Start=mysql_result($result,$i,"Start"); $End=mysql_result($result,$i,"End"); $Frequency=mysql_result($result,$i,"Frequency"); $Service=mysql_result($result,$i,"Service"); $Severity=mysql_result($result,$i,"Severity"); $Direction=mysql_result($result,$i,"Direction"); $Location=mysql_result($result,$i,"Location"); $Atype=mysql_result($result,$i,"Atype"); $CompanyID=mysql_result($result,$i,"CompanyID"); $CustomerID=mysql_result($result,$i,"CustomerID"); $Description=mysql_result($result,$i,"Description"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><? echo $NetProcess; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $Node; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $Unit; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $Class; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $Date; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $Start; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $End; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $Frequency; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $Service; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $Severity; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $Direction; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $Location; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $Atype; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $CompanyID; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $CustomerID; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $Description; ?></font></td> </tr> <? $i++; } echo "</table>" ?> Hope my confusion will be solved. Its retriving only empty values. So somebody help me in this. Thanking you ri |
|
#2
|
||||
|
||||
|
try this:
PHP Code:
The trick is in that I changed the value so you don't get an endless amount of radio buttons with value 'N', so the next script can actually distinguish what button was selected. The <label> is there so you can click the text instead of the readio button, just a little HTML trick. |
|
#3
|
|||
|
|||
|
Thank you so much
Thank you so much, it worked.
Can you suggest some good books or websites, that teaches all these type of scripts with practical examples. It would be great, if there is one. Thank you once again. ri |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Populating from Radio Button |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|