instantly updating php database
Posted: Sat Oct 06, 2007 6:21 pm
feyd | Please use
and then the page will update without reloading... so far I am using this javascript:[/syntax]
I got stuck trying to transfer data from the javascript function to the php part of it.... how can i do this?? or is there a better way to do an instand update thing?
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I am trying to make data be sent to a mySQL database instatnly on the click of a button:
[syntax="html"]<INPUT TYPE=IMAGE src="images/post_private.png" OnClick="Java_Up(1);">
//the number will vary, 1 is just an example
and then the page will update without reloading... so far I am using this javascript:[/syntax]
Code: Select all
<script language="JavaScript">
<!-- Begin
function Java_Up(P_NUM) {
<?PHP
//this is where i do not know what to do. how can i get the post number from the javasrcipt function into this php?? (P_NUM)
$sql = "SELECT * from table WHERE postid='$postnum,' ORDER BY postid DESC";
$result = mysql_query($sql) or print ("Can't select entry from table php_blog.<br />" . $sql . "<br />" . mysql_error());
while($row = mysql_fetch_array($result)){
$prev = stripslashes($row['shared']);
if($prev == "false"){
$result = mysql_query("UPDATE table_digposts SET shared='true' WHERE postid='$postnum' LIMIT 1") or print ("Can't update entry.<br />" . mysql_error());
} else {
$result = mysql_query("UPDATE table_digposts SET shared='false' WHERE postid='$postnum' LIMIT 1") or print ("Can't update entry.<br />" . mysql_error());
}
?>
}
// End -->
</script>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]