I have PHP page and i am trying user can update phone number when click on EDIT button.
For that i created 1 button and when user click on EDIT the button changed to SAVE and now user enter phone number and press save button. Now user click save button i want to save that phone number in database so i want to execute query. I tried to add PHP code in javascript but its not working.
This is the button code. I am showing phone number from database. That works fine.
<input name='wophno' type='text' id='wophno' maxlength='10' disabled='disabled' value=".$res['PHONE_NUMBER'].">
<input type='button' value='Edit' id='editMno' name='editMno' onclick='update_mono()'>
onClick() i am calling javascript function update_mono()
function update_mono()
{
var btnval = document.getElementById('editMno').value;
if(document.getElementById('editMno').value == 'Edit')
{
document.getElementById('mophno').disabled = false;
document.getElementById('mophno').focus();
document.getElementById('editMno').value = 'Save';
}
else
{
var mno = document.getElementById('mophno').value;
<?php
$sql_mono = $_GET[$person_id];
$sql_mono="SELECT phone_number FROM PHONE P WHERE P.Person_ID =".$person_id." AND P.phone_type_code like 'M'";
$s = @OCIRowCount($sql_mono);
echo "document.write('" . $s . "');";
if($s == 1)
{
$sql_upmono="UPDATE PHONE SET created_date = sysdate, phone_number = " ?>mno <?php " WHERE Person_ID =".$person_id." AND phone_type_code = 'M'";
}
else
{
$sql_upmono="INSERT INTO PHONE VALUES(".$person_id.",'M',"?> mno <?php ",sysdate)";
}
$s = oci_parse($conn, $sql_upmono);
oci_execute($s);
?>
document.getElementById('mophno').disabled = true;
document.getElementById('editMno').value = 'Edit';
}
}
Please help me what is wrong with this code. How to call PHP code in javascript.
Thanks for help.