Jump to content

Checking error & update


austine_power007

Recommended Posts

ok this is just for one condition i have more
[code]while($row = odbc_fetch_array($query))
{
            $titl = ($row['title']);
$start_dat = ($row['start_date']);
$start = date("d/m/y", strtotime($start_dat));
$est_end_date = ($row['est_end_date']);
$end = date("d/m/y", strtotime($est_end_date));
$actual_end_date = ($row['actual_end_date']);
$actual = date("d/m/y", strtotime($actual_end_date));
$complete = ($row['complete']);
$remark = ($row['remark']);


if(odbc_num_rows($query)== 0)
echo"No Data";
    elseif(($complete)<100)
    {

    if(($complete)>50 and ($complete) <100)
{
echo"
  <tr> 
    <td style=color:blue width='139' height='26'><div align='left'><strong>$titl</strong></dv></td>
    <td style=color:blue width='80'><div align='center'><strong>$start</strong></dv></td>
    <td style=color:blue width='94'><div align='center'><strong>$end</strong></dv></td>
    <td style=color:blue width='91'><div align='center'><strong>$actual</strong></dv></td>
    <td width='20'><div align='center'><input name='comp1' type='text'  id='comp1' value=\"{$complete}\" size='02'></div></td>
<td style=color:blue width='237'><div align='left'><strong>$remark</strong></dv></td>
</tr> "; 
}
elseif(($complete)<=50)
{

echo"
  <tr> 
    <td style=color:red width='139' height='26'><div align='left'><strong>$titl</strong></dv></td>
    <td style=color:red width='80'><div align='center'><strong>$start</strong></dv></td>
    <td style=color:red width='94'><div align='center'><strong>$end</strong></dv></td>
    <td style=color:red width='91'><div align='center'><strong>$actual</strong></dv></td>
    <td width='20'><div align='center'><input name='comp2' type='text'  id='comp2' value=\"{$complete}\" size='02'></div></td>
<td style=color:red width='237'><div align='left'><strong>$remark</strong></dv></td>

  </tr>
"; 
}  

...........other codes and HTML
[/code]

and [code]<td width='20'><div align='center'><input name='comp1' type='text'  id='comp1' value=\"{$complete}\" size='02'></div></td>[/code]
for showing output in a text field so that user can change the value.
i used a [b]java script[/b] so that user don't give the wrong data type.
Link to comment
https://forums.phpfreaks.com/topic/30437-checking-error-update/
Share on other sites

here is the script:
[code]<script>
function formValidator()
{
// Make quick references to our fields


var comp1 = document.getElementById('comp1');
var comp2 = document.getElementById('comp2');



// Check each input in the order that it appears in the form!

if(isNumeric(comp1, "Please enter a valid Number (0-100)"))
{

if(isNumeric(comp2, "Please enter a valid Number (0-100)"))
{
}
}

return false;

}

function isEmpty(elem, helperMsg){
if(elem.value.length == 0){
alert(helperMsg);
elem.focus(); // set the focus to this input
return true;
}
return false;
}

function isNumeric(elem, helperMsg)
{
var numericExpression = /^[0-9]+$/;
if(elem.value.match(numericExpression))
{

if(elem.value < 0)
{
alert(helperMsg);
elem.focus();
return false;
}

if(elem.value > 100)
{
alert(helperMsg);
elem.focus();
return false;
}
else
return true;

}
else
{
alert(helperMsg);
elem.focus();
return false;
}
}



</script>[/code]
there is [b]two variable[/b] because i have another condition but
[color=red][b]the problem is when i insert wrong data it only checks two field but when i fetch db it have more then 2 field because i have while statement so when i change the value of the text field it checks for only two field but for other field it didn't check. why?? [/b][/color]
Link to comment
https://forums.phpfreaks.com/topic/30437-checking-error-update/#findComment-140159
Share on other sites

[quote author=fenway link=topic=118397.msg485858#msg485858 date=1166229804]
Because you only have comp1 & comp2 hard-coded...
[/quote][quote author=fenway link=topic=118397.msg485858#msg485858 date=1166229804]
Because you only have comp1 & comp2 hard-coded...
[/quote]

so what is the solution for this plzz help me
Link to comment
https://forums.phpfreaks.com/topic/30437-checking-error-update/#findComment-142929
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.