newphpbees
29 Feb 2012, 03:38 AM
Hi..
I have while loop inside while loop but I encountered problem in displaying data inside while loop or the second while loop.
here is my code:
<?php
error_reporting(0);
$con = mysql_connect('localhost', 'root','');
if (!$con) {
echo 'failed';
die();
}
mysql_select_db("mes", $con);
?>
<script type="text/javascript">
function showDetails(pcode) {
var clickElement = pcode.value;
var click_id = pcode.id;
// var value_ = document.getElementById(click_id).checked
// = document.getElementById(clickElement).checked;
//var Table = (document.getElementsByName('list')[0].value);
var Table = document.getElementById('kanban_list');
var rows = Table.rows;
var strSelect = document.getElementById(click_id).value;
//alert(strSelect)
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
//row.style.display = (row.id.substr(0,3) == strSelect) ? 'none' : '';
//row.style.display = (row.id.substr(0,3) == strSelect) ?
// row.style.display = 'none';
// row.style.display = '';
if (row.id.substr(0,3) == strSelect) {
row.style.display = ((document.getElementById(click_id).checked) == false) ? 'none' : ''
}
//(document.getElementById(click_id).checked == false) ? 'none' : '' : '';
}
}
</script>
<?php
$sql = "SELECT kc.PCODE, kc.count_wip_chemical_weighing, kc.count_wip_compounding, kc.count_wip_extrusion,
kc.count_wip_forming, kc.count_wip_deflashing, kc.kanban, kc.virtual, p.max_lot, p.min_lot FROM kanban_checker kc
JOIN plan p ON kc.PCODE = p.PCODE ORDER BY p.PCODE";
$result = mysql_query($sql, $con);
?><label>Display Details:</label><input onclick='showDetails(this);' id='chkDetail' type='checkbox' checked='checked' value='wip'/>
<?php
echo "<table id='kanban_list'>";
echo "<tr>
<th> PCODE </th>
<th> LOT CODE </th>
<th> CHEMICAL WEIGHING </th>
<th> COMPOUNDING </th>
<th> EXTRUSION </th>
<th> FORMING </th>
<th> DEFLASHING </th>
<th> KANBAN </th>
<th> VIRTUAL </th>
<th> MAX LOT </th>
<th> MIN LOT </th>
</tr>";
while($row = mysql_fetch_assoc($result)){
echo "<tr>
<td>$row[PCODE]</td>
<td> </td>
<!-- <td>$row[LOT_CODE]</td> -->
<td>$row[count_wip_chemical_weighing]</td>
<td>$row[count_wip_compounding]</td>
<td>$row[count_wip_extrusion]</td>
<td>$row[count_wip_forming]</td>
<td>$row[count_wip_deflashing]</td>
<td>$row[kanban]</td>
<td>$row[virtual]</td>
<td>$row[max_lot]</td>
<td>$row[min_lot]</td>
</tr>";
$sql = "SELECT kd.LOT_CODE, kd.wip_chemicalweighing, kd.wip_compounding, kd.wip_extrusion, kd.wip_forming, kd.wip_deflashing
FROM kanban_data kd JOIN plan p ON kd.PCODE = p.PCODE ORDER BY p.PCODE ";
$result_kanban_data = mysql_query($sql, $con);
while($row_data = mysql_fetch_assoc($result_kanban_data)){
echo "<tr id='wip'>
<td></td>
<td> $row_data[LOT_CODE]</td>
<td> $row_data[wip_chemicalweighing]</td>
<td> $row_data[wip_compounding]</td>
<td> $row_data[wip_extrusion]</td>
<td> $row_data[wip_forming]</td>
<td> $row_data[wip_deflashing]</td>
</tr>";
}
}
echo "</table>";
?>
I attach the image of result from this code
But the output that I want is all LOT_CODE with P35 PCODE will only display below P35
and all LOTCODE with P35M PCODE will only display below P35M.
Thank you
I hope somebody can help me..
I have while loop inside while loop but I encountered problem in displaying data inside while loop or the second while loop.
here is my code:
<?php
error_reporting(0);
$con = mysql_connect('localhost', 'root','');
if (!$con) {
echo 'failed';
die();
}
mysql_select_db("mes", $con);
?>
<script type="text/javascript">
function showDetails(pcode) {
var clickElement = pcode.value;
var click_id = pcode.id;
// var value_ = document.getElementById(click_id).checked
// = document.getElementById(clickElement).checked;
//var Table = (document.getElementsByName('list')[0].value);
var Table = document.getElementById('kanban_list');
var rows = Table.rows;
var strSelect = document.getElementById(click_id).value;
//alert(strSelect)
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
//row.style.display = (row.id.substr(0,3) == strSelect) ? 'none' : '';
//row.style.display = (row.id.substr(0,3) == strSelect) ?
// row.style.display = 'none';
// row.style.display = '';
if (row.id.substr(0,3) == strSelect) {
row.style.display = ((document.getElementById(click_id).checked) == false) ? 'none' : ''
}
//(document.getElementById(click_id).checked == false) ? 'none' : '' : '';
}
}
</script>
<?php
$sql = "SELECT kc.PCODE, kc.count_wip_chemical_weighing, kc.count_wip_compounding, kc.count_wip_extrusion,
kc.count_wip_forming, kc.count_wip_deflashing, kc.kanban, kc.virtual, p.max_lot, p.min_lot FROM kanban_checker kc
JOIN plan p ON kc.PCODE = p.PCODE ORDER BY p.PCODE";
$result = mysql_query($sql, $con);
?><label>Display Details:</label><input onclick='showDetails(this);' id='chkDetail' type='checkbox' checked='checked' value='wip'/>
<?php
echo "<table id='kanban_list'>";
echo "<tr>
<th> PCODE </th>
<th> LOT CODE </th>
<th> CHEMICAL WEIGHING </th>
<th> COMPOUNDING </th>
<th> EXTRUSION </th>
<th> FORMING </th>
<th> DEFLASHING </th>
<th> KANBAN </th>
<th> VIRTUAL </th>
<th> MAX LOT </th>
<th> MIN LOT </th>
</tr>";
while($row = mysql_fetch_assoc($result)){
echo "<tr>
<td>$row[PCODE]</td>
<td> </td>
<!-- <td>$row[LOT_CODE]</td> -->
<td>$row[count_wip_chemical_weighing]</td>
<td>$row[count_wip_compounding]</td>
<td>$row[count_wip_extrusion]</td>
<td>$row[count_wip_forming]</td>
<td>$row[count_wip_deflashing]</td>
<td>$row[kanban]</td>
<td>$row[virtual]</td>
<td>$row[max_lot]</td>
<td>$row[min_lot]</td>
</tr>";
$sql = "SELECT kd.LOT_CODE, kd.wip_chemicalweighing, kd.wip_compounding, kd.wip_extrusion, kd.wip_forming, kd.wip_deflashing
FROM kanban_data kd JOIN plan p ON kd.PCODE = p.PCODE ORDER BY p.PCODE ";
$result_kanban_data = mysql_query($sql, $con);
while($row_data = mysql_fetch_assoc($result_kanban_data)){
echo "<tr id='wip'>
<td></td>
<td> $row_data[LOT_CODE]</td>
<td> $row_data[wip_chemicalweighing]</td>
<td> $row_data[wip_compounding]</td>
<td> $row_data[wip_extrusion]</td>
<td> $row_data[wip_forming]</td>
<td> $row_data[wip_deflashing]</td>
</tr>";
}
}
echo "</table>";
?>
I attach the image of result from this code
But the output that I want is all LOT_CODE with P35 PCODE will only display below P35
and all LOTCODE with P35M PCODE will only display below P35M.
Thank you
I hope somebody can help me..