PDA

View Full Version : Problem in SELECT option with condition



newphpbees
15 Mar 2012, 07:35 PM
Hi..

I got problem in logic on my problem in select option.

Here is my scenario.

I have select option which has a compound list:

example:

P28
P30
P32
P33
P35


and I have tables which has a total count of
compound that was already transact.

for example I already transact
10 P28 compound.

it will save in kanban_checker table field Total.

and I have parameter_settings table which has the maximum and minimum per compound:

fields----------data
P28------------P28
P28_max-----10
P28_min------6
P30------------P28
P30_max-----10
P30_min------6
P32------------P28
P32_max-----10
P32_min------6
P33------------P28
P33_max-----10
P33_min------6


now the logic is:

if P28 total = P28_max then notify that he already reach the maximum..it will not produce P28 because he already reach the maximum.

if P28 total = P28_min then produce P28.

same with other compound.

Now, I got a problem in coding and logic, because in the select option I'm not the one who code it.. I just one who need to add the additional function..

here is the code for select option and the function that was created by other,



$smarty->assign('text_name1','Compound Code');
$smarty->assign('compoundIndexValue', array('0', 'P28', 'P30', 'P32', 'P33', 'P35', 'P35M', 'P38', 'P40', 'P41', 'P42', 'P43', 'P46', 'P47', 'PXX', 'P35W'));

<tr>
<td class="tdMainText">{$text_name1}</td>

<td> <select class="tdMainElement" id="selCompound" onchange="isSelected('selCompound','txtLotCode')" onclick="clearNotify()" onblur="this.focus();" onkeypress="return false">{html_options values=$compoundIndexValue output=$names selected="0"} </select> </td>
</tr>

<script type="text/javascript">
function isSelected(obj1, obj2) {

if (!document.getElementById(obj1).disabled) {
document.getElementById(obj1).disabled = true;
}

if (document.getElementById('clear').disabled) {
document.getElementById('clear').disabled = false; //enable it
}

if ((document.getElementById('chkDownGrade') != null)) {
if (!document.getElementById('chkDownGrade').disabled) {
document.getElementById('chkDownGrade').disabled = true;
}
}


if (document.getElementById(obj2).disabled) {
document.getElementById(obj2).disabled = false;
}
document.getElementById(obj2).focus();
document.getElementById(obj2).focus();

//notify("Gain Maximum Total");

}

function disable() {
if (!document.getElementById('clear').disabled) {
document.getElementById('clear').disabled = true;
}
else {
document.getElementById('clear').disabled = false;
}

}

function clearNotify() {

if (document.getElementById('notice') != null) {
document.getElementsByTagName('body')[0].removeChild(document.getElementById('notice')) //>> clear the box }
}
</script>



and here is the code that I tried to add:



$compound = mysql_real_escape_string($_POST['compound']);
$sql = "SELECT
P28, P28_max, P28_min,
P30, P30_max, P30_min,
P32, P32_max, P32_min,
P33, P33_max, P33_min,
P35, P35_max, P35_min,
P35M, P35M_max, P35M_min,
P35W, P35W_max, P35W_min,
P38, P38_max, P38_min,
P41, P41_max, P41_min,
P42, P42_max, P42_min,
P43, P43_max, P43_min,
P46, P46_max, P46_min
FROM parameter_settings";
$res_pcode = mysql_query($sql, $con);

while($row = mysql_fetch_assoc($res_pcode)){
$P28 = $row['P28'];
$P28_max = $row['P28_max'];
$P28_min = $row['P28_min'];

$P30 = $row['P30'];
$P30_max = $row['P30_max'];
$P30_min = $row['P30_min'];

$P32 = $row['P32'];
$P32_max = $row['P32_max'];
$P32_min = $row['P32_min'];

$P33 = $row['P33'];
$P33_max = $row['P33_max'];
$P33_min = $row['P33_min'];

$P35 = $row['P35'];
$P35_max = $row['P35_max'];
$P35_min = $row['P35_min'];

$P35M = $row['P35M'];
$P35M_max = $row['P35M_max'];
$P35M_min = $row['P35M_min'];

$P35W = $row['P35W'];
$P35W_max = $row['P35W_max'];
$P35W_min = $row['P35W_min'];

$P38 = $row['P38'];
$P38_max = $row['P38_max'];
$P38_min = $row['P38_min'];

$P41 = $row['P41'];
$P41_max = $row['P41_max'];
$P41_min = $row['P41_min'];

$P42 = $row['P42'];
$P42_max = $row['P42_max'];
$P42_min = $row['P42_min'];

$P43 = $row['P43'];
$P43_max = $row['P43_max'];
$P43_min = $row['P43_min'];

$P46 = $row['P46'];
$P46_max = $row['P46_max'];
$P46_min = $row['P46_min'];

$P47 = $row['P47'];
$P47_max = $row['P47_max'];
$P47_min = $row['P47_min'];
}
// $sub_lotcode = substr($lotCode, 9, 4);

$sql = "SELECT PCODE, total FROM kanba_checker WHERE PCODE = '$sub_lotcode' ORDER BY PCODE";
$res_kanban = mysql_query($sql, $con);

$row_kanban = mysql_fetch_assoc($res_kanban);

$PCODE = $row_kanban['PCODE'];
$total = $row_kanban['total'];

if($compound = $P28 || $total == $P28_max){
echo "<script type='text/javascript'>alert(P28 gain total maximum)</script>";
}
else{

}


but I don't know if my code and my logic is correct.

I think I did to add function.

But I don't know how..

I hope someone can help me or guide me to solve my problem.

Thank you so much..

jassmee
09 Apr 2012, 12:13 AM
I think expert developer provide the better information... you may consultant with developer... but according to me you are not using proper syntax..