...

View Full Version : updating record status with button



Jaminxz
03-04-2009, 12:17 PM
Hello, firstly this is a bit of a gray area so it could possibly belong in another forum such as javascript, HTML help or something, but since i think the problem is php related i'm going to post it here (sorry if i'm wrong!).

I have a php page which displays results from a MySQL table if a record's status is set to 'Open'. Every row has a 'close' button whch updates a records status to 'closed', here is the code for that:

Code: [Select]
<input type="submit" value="Close" ID="<?php echo $row_query4['ID']; ?>" onclick="return confirm_delete('<?php echo $row_query4['ID']; ?>')" />

Here is the Jscript:

Code: [Select]
<script type="text/javascript">

var form_id;
function confirm_delete(ID)
{
var cycles = prompt("Close at how many cycles?", " <?php echo $total_cycles ?>");

if(cycles){
var CycleClose = cycles;
var id = ID;
document.getElementById('IDval').value = id;
document.getElementById('CycleClose').value = CycleClose;
return true;
}
else
{
alert('You didn\'t provide a value for cycles.');
return false;
}

}
</script>
and the hidden form code

Code: [Select]
<input type="hidden" name="IDval" id="IDval"><input type="hidden" name="CycleClose" id="CycleClose">
and the php post code that accepts a value on postback:

Code: [Select]
//If IS_PostBack then database is to be updated
if(isset($_POST['IDval']) && isset($_POST['CycleClose'])){
// if($_POST) {
//echo "BADGERS";
$ID_Val = $_POST['IDval'];
$Cycles_Closed = $_POST['CycleClose'];

-----------SQL then executed here-------------
}

Basically on click of a button, the records status should be updated to 'closed', the page should refresh and then the table should be rebuilt (but not contain the row that has just been updated because its status is now 'closed').

this works perfectly in my local environment, but i've uploaded it to my college's webserver and it does not work properly: when the close button is clicked and then a value entered into the prompt box, the page refreshes and its totally white, the SQL update command doesnt get executed and thus the table isn't updated either.

I dont even know where to start debugging this, can anybody help?

thanks in advance,
jaminxz.

abduraooft
03-04-2009, 03:14 PM
the page refreshes and its totally white, the SQL update command doesnt get executed and thus the table isn't updated either. Guess you've something to do with http://www.codingforums.com/showthread.php?p=617060#post617060

masterofollies
03-04-2009, 04:09 PM
Please place your code inside the code tags.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum