Hossam El-Ansary
Hossam El-Ansary

Reputation: 11

javascript executing php code

i have a php web application project ... and i want to implement a javascript onclick code .. for example : when user clicks follow this post ... the MySQL query inserts into database that the user followed this ... so the page is refreshed and after that it will appear as FOLLOWED .. what's the javascript code needed to do this ... or is there any example may fit ??

here's a sample code

     <div id="main_content">


        <?php

        if(isset($_GET['et']))
        {
        $et = $_GET['et'];
        }
        $result = mysql_query("select * from events where event_type =$et") ;

        require_once('queries/category_extract.php') ;

        ?>

        <div id="body_content">
    <div id="event_tag">
        <a><?php echo $cattitle["categ_title"]?>s</a>
    </div>

    <?php
    while($row=mysql_fetch_array($result) )
    {

        require('queries/followers_extract.php') 
        ?>



        <div id="postpreview">
        <div id="postpreview_up">
            <div id="postpreview_up_left">
                    <div id="postpreview_up_left_left">
                        <a>Event Title :</a>
                    </div>

                    <div id="postpreview_up_left_right">
                    <a><?php echo $row["event_title"] ?></a> 
                    </div>
            </div>

              <div id="postpreview_up_right">
                <img src="images/read_more.gif" />
              </div>
        </div>

        <div id="postpreview_bottom">
            <div id="postpreview_bottom_left">
                <div id="postpreview_bottom_left_left">
                <a>Date :</a>
                </div>

                <div id="postpreview_bottom_left_right">
                <a><?php echo $row["event_date"] ?></a>
                </div>
            </div>
        <div id="postpreview_bottom_right">

                <div id="postpreview_bottom_right_left">
                <?php

                if($follower['follower_id'] ==NULL){echo " <img src='images/follow_button.jpg' /> " ; } 
                    else { echo " <img src='images/follow_closed.jpg' /> " ;}
                ?>
                </div>

                <div id="postpreview_bottom_right_right">
                <?php
                if($follower['follower_id'] !=NULL){ echo " <img src='images/following_button.jpg' /> " ; } 
                else { echo " <img src='images/following_Closed.jpg' /> " ;}

                ?>
                </div>
                <div id="postpreview_bottom_right_right">
                <?php
                if($follower['follower_id'] !=NULL){ echo " <img src='images/unfollow_button.jpg' /> " ; } 
                else { echo " <img src='images/unfollow_closed.jpg' />  " ;}

                ?>

                </div>

        </div>

        </div>

        </div>

        <div id="splitter"></div>
        <?php
    }
    ?>
   <!--End Of Post Preview-->

     <!--End Of Post Preview-->

Upvotes: 0

Views: 99

Answers (1)

Filippo oretti
Filippo oretti

Reputation: 49813

ok go for this: http://www.9lessons.info/2009/04/exactly-twitter-like-follow-and-remove.html

you have to learn the basics as i read.

Upvotes: 2

Related Questions