My text file is as follow:
我的文本文件如下:
12345 234 455
23 67 9666 13 56
1234 777 90012345 234 455 23 67 9666 13 56 1234 777 900
whenever I'm checking the preferred check-boxes only the first value of each line appear other value does not appear ,I mean like for the first line only 12345 is appearing and 234 455 don't appear ; Does any one help me? I need whenever I'm selecting any check boxes the complete line contain should be selected or appearing as well
每当我检查首选复选框时,只有每行的第一个值出现,其他值不会出现,我的意思是第一行只有12345出现而且234 455没有出现;有人帮助我吗?每当我选择任何复选框时,我都需要选择或显示完整的行包含
process.php
process.php
require 'connect.inc.php';
if(isset($_POST['check']) && ! empty($_POST['check']))
{
$check=$_POST['check'];
$numberOfCheck=count($check);
echo ("You have checked $numberOfCheck checkboxes : ");
for ($i=0; $i<$numberOfCheck; $i++)
{
echo '<br>';
echo ($check[$i]. " ");
$VarCheck=$check[$i];
$name=time();
$myFile=fopen($name,"a");
$txt=$VarCheck;
fwrite($myFile,$txt);
fclose($myFile);
}
}
else
{
echo "Zero check selected";
}
?>
This is my dynamic table generating according to the number of line of my file text
这是我根据文件文本行数生成的动态表
<?php
echo '<form method="POST" action="process.php">';
$file = fopen("text.txt","r");
echo '<table border="1">';
while(! feof($file))
{
$data= fgets($file);
echo '<tr>
<td><input type="checkbox" name="check[]" value='.$data.'</td>
<td>'.$data.'</td></tr>';
}
fclose($file);
echo '<input type="submit" value="send">';
echo '</form>';
?>
1 个解决方案
#1
1
You forget close (>
) your input tag and set the "
for the input value.
您忘记关闭(>)输入标记并设置“输入值”。
You must change this line:
你必须改变这一行:
<td><input type="checkbox" name="check[]" value='.$data.'</td>
to:
至:
<td><input type="checkbox" name="check[]" value="'.$data.'"></td>
EDIT Test with this:
用这个编辑测试:
File text.txt
文件text.txt
12345 234 455
23 67 9666 13 56
1234 777 900
Page 1.php
第1页.php
<?php
echo '<form method="POST" action="process.php">';
$file = fopen("text.txt","r");
echo '<table border="1">';
while(! feof($file))
{
$data= fgets($file);
if(trim($data) != '') {
echo '<tr>
<td><input type="checkbox" name="check[]" value="'.$data.'"></td>
<td>'.$data.'</td></tr>';
}
}
fclose($file);
echo '<input type="submit" value="send">';
echo '</form>';
?>
Page process.php
Page process.php
<?php
if(isset($_POST['check']) && ! empty($_POST['check']))
{
$check=$_POST['check'];
$numberOfCheck=count($check);
echo ("You have checked $numberOfCheck checkboxes : ");
for ($i=0; $i<$numberOfCheck; $i++)
{
echo '<br>';
echo ($check[$i]. " ");
$VarCheck=$check[$i];
$name=time();
$myFile=fopen($name,"a");
$txt=$VarCheck;
fwrite($myFile,$txt);
fclose($myFile);
}
}
else
{
echo "Zero check selected";
}
?>
#1
1
You forget close (>
) your input tag and set the "
for the input value.
您忘记关闭(>)输入标记并设置“输入值”。
You must change this line:
你必须改变这一行:
<td><input type="checkbox" name="check[]" value='.$data.'</td>
to:
至:
<td><input type="checkbox" name="check[]" value="'.$data.'"></td>
EDIT Test with this:
用这个编辑测试:
File text.txt
文件text.txt
12345 234 455
23 67 9666 13 56
1234 777 900
Page 1.php
第1页.php
<?php
echo '<form method="POST" action="process.php">';
$file = fopen("text.txt","r");
echo '<table border="1">';
while(! feof($file))
{
$data= fgets($file);
if(trim($data) != '') {
echo '<tr>
<td><input type="checkbox" name="check[]" value="'.$data.'"></td>
<td>'.$data.'</td></tr>';
}
}
fclose($file);
echo '<input type="submit" value="send">';
echo '</form>';
?>
Page process.php
Page process.php
<?php
if(isset($_POST['check']) && ! empty($_POST['check']))
{
$check=$_POST['check'];
$numberOfCheck=count($check);
echo ("You have checked $numberOfCheck checkboxes : ");
for ($i=0; $i<$numberOfCheck; $i++)
{
echo '<br>';
echo ($check[$i]. " ");
$VarCheck=$check[$i];
$name=time();
$myFile=fopen($name,"a");
$txt=$VarCheck;
fwrite($myFile,$txt);
fclose($myFile);
}
}
else
{
echo "Zero check selected";
}
?>