PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 13th, 2004, 06:07 PM
ramyaivan ramyaivan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 16 ramyaivan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old August 14th, 2004, 01:58 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 995 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 797501 Folding Title: Super Ultimate Folder - Level 2Folding Points: 797501 Folding Title: Super Ultimate Folder - Level 2Folding Points: 797501 Folding Title: Super Ultimate Folder - Level 2Folding Points: 797501 Folding Title: Super Ultimate Folder - Level 2Folding Points: 797501 Folding Title: Super Ultimate Folder - Level 2Folding Points: 797501 Folding Title: Super Ultimate Folder - Level 2Folding Points: 797501 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 13 h 57 m 35 sec
Reputation Power: 5
Send a message via ICQ to Itsacon
try this:
PHP Code:
 $NP=$row["NetProcess"];
echo 
"<label><input type=\"radio\" name=\"N\" value=\"".$NP."\"> $NP</label>"


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.

Reply With Quote
  #3  
Old August 14th, 2004, 12:06 PM
ramyaivan ramyaivan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 16 ramyaivan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Populating from Radio Button


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT