Jump to content

Implement PHP code into Ajax


skter4938

Recommended Posts

Hello. I have this question that I cannot possibly get working.

 

Alright, let me explain. I have a button which is called "bookmark". When that button is clicked, it goes to a page called "bookmark.php" and then executes a peice of code which adds that file to you bookmarks.

 

Now what I want to do is have a image named "bookmark" which will be a little '+' sign. When that image is clicked, the bookmark.php code is executed BUT WITHOUT CHANGING THE PAGE. aka using Ajax.

 

and if that file has already been bookmarked the image will be a little '-' sign.

 

So here is my bookmark.php code:

<?
require_once("include/main.php");
dbconn();
loggedinorreturn();

function bark($msg) {
stdhead();
   stdmsg("w00t!", $msg);
stdfoot();
exit;
}

if (!isset($_GET[file]))
       bark ("Faild ... No file selected");


if ((get_row_count("bookmarks", "WHERE userid=$CURUSER[id] AND fileid = $_GET[file]")) > 0)
       bark("Already bookmarked $_GET[file]");

mysql_query("INSERT INTO bookmarks (userid, fileid) VALUES ($CURUSER[id], $_GET[file])") or sqlerr(__FILE__,__LINE__);

bark ("Successfully bookmarked");



?>

 

and here is the image of the way it goes to the boomark.php page.

asdasws3.png

 

 

the little + sign is the bookmark.php button thing, and the arrow is the download button.

 

-Artem

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.