Page 1 of 1

error $_POST[]

Posted: Wed Aug 16, 2006 4:52 am
by shiranwas
hi,

i have a table which is populated with data in a table in PHP tags the first column creates ratio buttons with the value assign from the table field, my problam is when iclik the submit button all the value in the <form> tag can be retrieved but not the value of the radio button using

$jobno=$_POST['optSelected'];

i think, i don't know, it's because of the table not created with the <form> tags.

can anyone solve this problam please

<html>

Code: Select all

<?php



include('Conn.php');
$sql="Select entered,jobno,ffrom,keyword,message from tblcomplaints where completed='N' order by jobno LIMIT 10";

	$uqery=mysql_query($sql) or die('some error occured while querung the database.');
			echo "<div id='Layer1' style='position:absolute; left:50px; top:140px; width:1500px; height:142px; z-index:1; '> ";
			echo "<table border=0 bordercolor='#DEE3E7' cellpadding=0 id='data'>";
		
				echo "<tr  bgcolor='#DEE3E7' >";
				echo "<font size=2>";
				echo "<th width='5' >se";
				echo "<th width='50' >Date";
				echo "<th width='60'>Job No";
				echo "<th width='150'>From";
				echo "<th width='100'>keyword";
				echo "<th width='360'>Message";
				echo"</tr>";
				
				$count=0;
								
				while($rows=mysql_fetch_row($uqery)){			
									
						echo "<tr bgcolor='E2F3F1' >";	
					
						echo "<font size=1>	";
					
						echo "<td height='5' ><input name='optSelected' type='radio' value='.$rows[0].' onclick='javascript:showValue()' ></td>";
						
						echo "<td height='5' >".$rows[0]."</td>";
						echo "<td height='5'>".$rows[1]."</td>";
						echo "<td height='5'>".$rows[2]."</td>";
						echo "<td height='5'>".$rows[3]."</td>";
						$message= substr($rows[4],0,48);						
						echo "<td height='5'>".$message."</td>";
						
						echo "</font>";
					echo "</tr>";		
						$count=$count+1;		
						
				}								
			echo "</table>";
			echo "</div>";	

?>

<body>
<form action="assignBack.php" method="post" name="shiran">

<input type="submit" name="cmdOK" value="SAVE" >

</form>
</body>
</html>

Posted: Wed Aug 16, 2006 5:08 am
by CoderGoblin
The values you would like to be in the $_POST have to be between the form tags.

Posted: Wed Aug 16, 2006 5:28 am
by shiranwas
please tell me how to include a dynamically creating table between the form tags where submit button is in.


thanks

Posted: Wed Aug 16, 2006 6:36 am
by CoderGoblin

Code: Select all

<?php
include('Conn.php');
$body="";
$sql="Select entered,jobno,ffrom,keyword,message from tblcomplaints where completed='N' order by jobno LIMIT 10";

$uqery=mysql_query($sql) or die('some error occured while querung the database.');
$body.= "<div id='Layer1' style='position:absolute; left:50px; top:140px; width:1500px; height:142px; z-index:1; '> ";
$body.= "<table border=0 bordercolor='#DEE3E7' cellpadding=0 id='data'>";
$body.= "<tr  bgcolor='#DEE3E7' >";
$body.= "<font size=2>";
$body.= "<th width='5' >se";
$body.= "<th width='50' >Date";
$body.= "<th width='60'>Job No";
$body.= "<th width='150'>From";
$body.= "<th width='100'>keyword";
$body.= "<th width='360'>Message";
$body.="</tr>";
$count=0;
while($rows=mysql_fetch_row($uqery)){         
  $body.= "<tr bgcolor='E2F3F1' >"; 
  $body.= "<font size=1>     ";
  $body.= "<td height='5' ><input name='optSelected' type='radio' value='.$rows[0].' onclick='javascript:showValue()' ></td>";
  $body.= "<td height='5' >".$rows[0]."</td>";
  $body.= "<td height='5'>".$rows[1]."</td>";
  $body.= "<td height='5'>".$rows[2]."</td>";
  $body.= "<td height='5'>".$rows[3]."</td>";
  $message= substr($rows[4],0,48);                                               
  $body.= "<td height='5'>".$message."</td>";
  $body.= "</font>";
  $body.= "</tr>";      
  $count=$count+1;               
}                                                        
$body.= "</table>";
$body.= "</div>"; 
?> 
<body>
  <form action="assignBack.php" method="post" name="shiran">
    <?php echo($body); ?>
    <input type="submit" name="cmdOK" value="SAVE" >
  </form>
</body>
</html>
is one way. I generally build the whole page as a variable (including <html><head> etc) and output the result in a single echo command at the end, or have a template file and substitute bits and pieces using str_replace.

Posted: Wed Aug 16, 2006 7:30 am
by shiranwas
thank you very much for the kind help and appreciate it

thanks again