I'm trying to show a field from the database, where the database field starts off as saying textbox, like this:
307 , o = o ~ ongoing ~ (textbox) [approve button]
and I want to be able to be change the value in the textbox to say lala and then press the approve button and have it update the field with the new value in the database and with the window.location.reload(); it would show the updated field value in the textbox so it ends up like this:
307 , o = o ~ ongoing ~ (lala) [approve button]
Here's the code from views.php:
echo "<br><b>request to join site: {$row9['count']}</b><br>";
while ($row99 = $prep99->fetch(PDO::FETCH_ASSOC)) {
echo "{$row99['starID']} , {$row99['starName']} = {$row99['twitter']}";
if ($row99['guest'] == 0) {
$guest = 'ongoing';
};
if ($row99['guest'] == 1) {
$guest = 'guest';
};
if ($row99['guest'] == 2) {
$guest = 'PLEASE SELECT ONE';
};
echo " ~ $guest ~ <br>";
echo "<input type='text' name='starurl' value='{$row99['starURL']}' id='starurl' style='width:100px; height:30px;'/>";
echo "<br><button onclick='save_a9({$row99['starID']})'>Approve</button><button onclick='save_d9({$row99['starID']})'>Disapprove</button><br>";
}
Here's the function from the top of views.php:
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
function save_a9(id) {
$.post('response6.php', {starID:id, starURL: $('#starurl').val()}, function(result) {
alert(result);
window.location.reload();
});
}
</script>
And here's the response6.php:
<?php
include("db_conn.php");
$sql = "update stars set approved = 1, starURL = ? where starID = ?";
$qc = $pdo_conn->prepare($sql);
$qc->execute(array($_POST['starURL'], $_POST['starID']));
echo 'saved';
?>
UPDATE ON STATUS: It nearly works just this part is leaving starURL value blank {starID:id, starURL: $('#starurl').val()}
on the firebug console under post it shows this: starID=307&starURL=