ajax to pass variable

Discussion in 'JavaScript' started by vikaspa, Sep 20, 2012.

  1. #1
    i tried jquery

    http://paragkarve.com/photogallery02.php?cid=55&&subcid=48

    thumbnails are displayed.
    click on it pops up the bigger image using JQUERY. this is working fine ...

    however i want to

    display image name(picture name) and a link for enquiry on top of the image....

    in short what i want is..

    when clicked on thumbnail its Id will be passed (using ajax) and layer will be fill up (populated) with

    Image name
    Inquiry button and
    image.....

    Please help




    <?php
    $module="properties";
    $pagename='gallery';
    include_once("includes/dbconnect.php");
    include_once("includes/config.inc.php");
    //include_once("../includes/authorize.php");
    include_once("functions.inc.php");
    include_once("paginator.class.php");
    //include_once("../fckeditor/fckeditor.php");
    $id=$_REQUEST['id'];
    $lp=$_REQUEST['subcid'];
    $cid=$_REQUEST['cid'];

    $mquery="select * from mydetails ";
    mysql_select_db($database_DBconnect, $DBconnect);
    $mResult = mysql_query($mquery, $DBconnect) or die(mysql_error());
    $mrows = mysql_fetch_assoc($mResult);
    $mtotalrows=mysql_num_rows($mResult);

    $vsquery=sprintf("select * from gallery where cid=%s and lp =%s ", $cid,$lp);


    mysql_select_db($database_DBconnect, $DBconnect);
    $vsResult = mysql_query($vsquery, $DBconnect) or die(mysql_error());
    $vsrows = mysql_fetch_assoc($vsResult);
    $vstotalrows=mysql_num_rows($vsResult);
    //echo "<br> Query ".$vsquery." total rows ".$vstotalrows;
    $pages = new Paginator;
    //$pages->items_total = $num_rows[0];
    $pages->items_total=$vstotalrows;
    $pages->mid_range = 10;
    $pages->paginate();

    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>
    <link href="paragcss.css" rel="stylesheet" type="text/css" />

    <style>
    #imageWrap {
    width: 640px;
    height: 420px;
    background: url('ajax-loader.gif') center center no-repeat;
    left: 131px;
    top: 192px;
    }
    </style>

    <script src="javascript/jquery-1.4.2.js"></script>
    <script> $(document).ready(function () {
    $("#imageWrap").click(function () {
    $('#imageWrap').hide();

    });
    });
    $(document).ready(function() {
    $('#imageWrap').hide(300);
    $('.thumbnail').live("click", function() {
    $('#mainImage').hide();
    $('#imageWrap').css('background-image', "url('ajax-loader.gif')");
    var i = $('<img />').attr('src',this.href).load(function() {
    $('#mainImage').attr('src', i.attr('src'));
    $('#imageWrap').css('background-image', 'none');
    $('#imageWrap').fadeIn();
    $('#mainImage').fadeIn();
    });
    return false;
    });
    });</script>
    </head>

    <body>
    <a href="homeslideimages/bigwebsite 1.jpg"class="thumbnail"><img src="redarrow2.jpg"
    alt="Image 1"/></a>
    <a href="homeslideimages/bigwebsite 2.jpg" class="thumbnail"><img src="redarrow3.jpg"
    alt="Thumbnail 2"/></a>




    <table id="Table_01" width="1000" border="0" cellpadding="0" cellspacing="0" align="center">
    <tr>
    <td colspan="2"><?php include_once("heading.php");?>
    </td>
    </tr>

    </tr>
    <tr>
    <td width="1000" height="520" colspan="2" align="center" valign="top" >
    <div ><table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
    <?php $query=sprintf("SELECT * from stdtext " );
    //echo $query;
    mysql_select_db($database_DBconnect, $DBconnect);
    $Result = mysql_query($query, $DBconnect) or die(mysql_error());
    $rows = mysql_fetch_assoc($Result);
    $totalrows=mysql_num_rows($Result);
    ?> <tr>
    <td width="3%">&nbsp;</td>
    <td width="97%" class="captionoyellow"><div >

    &nbsp;<span class="text14turkish">&nbsp;</span><span class="text14orange">Image Gallery for <strong><?php echo Categoryname($cid)." in ". Subcategoryname($lp);?> Position </strong></span><span class="text14white">No.of Images <?php echo $vstotalrows;?><br />Please click on image to view it in bigger size </span>

    </div>
    <div ><?php $squery="SELECT * FROM subcategory WHERE id!=".$lp." ";
    // echo $squery;
    mysql_select_db($database_DBconnect, $DBconnect);
    $sResult = mysql_query($squery, $DBconnect) or die(mysql_error());
    $srows = mysql_fetch_assoc($sResult);
    $stotalrows=mysql_num_rows($sResult);?>
    <a href="photogallery.php?cid=<?php echo $cid;?>&&subcid=<?php echo $srows['id'];?>" id="m">Click here to View images in <?php
    echo $srows['name'] ;?> Position </a>&nbsp;&nbsp;&nbsp; <span class="text14white">Page Number </span><span class="text11">(click to view paintings)</span><span class="text12space4"> <?php echo $pages->display_pages();?><?php echo "<span style='\' margin-left:25px\'> ". $pages->display_jump_menu()
    . $pages->display_items_per_page() . "</span>";?></span></div></td>
    </tr>
    <tr>

    <td class="captionoyellow" bgcolor="#669999" height="1" colspan="2"> </td>
    </tr>
    </table></div>
    <!-- content block -->


    <table width="100%" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td width="69%"><table width="100%" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td align="center" valign="top" class="Line"><table width="100%" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td width="69%"><table width="100%" border="0" cellspacing="1" cellpadding="0">
    </table>

    <div class="box">
    <table width="100%" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td width="69%"><table width="100%" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td align="center" valign="top" class="Line"><table width="100%" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td width="69%"><table width="100%" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td align="center" valign="top" class="Line" colspan=3><table width="100%" border="0" cellspacing="0" cellpadding="0" >
    <tr>
    <td width="34%" align="left" class="text14orange">&nbsp;</td>
    <td width="1%" align="left">&nbsp;</td>
    <td width="65%" >&nbsp;</td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <?php
    // $query=sprintf("SELECT * from gallery where cid=%d and lp=%s and status=1 order by srno desc ",$cid , $lp);
    $query=sprintf("SELECT * from gallery where cid=%s and lp =%s and status=1 order by srno desc $pages->limit ", $cid,$lp);
    // echo $query;
    mysql_select_db($database_DBconnect, $DBconnect);
    $Result = mysql_query($query, $DBconnect) or die(mysql_error());
    $rows = mysql_fetch_assoc($Result);
    $totalrows=mysql_num_rows($Result);
    echo $query." ".$totalrows;

    if ($totalrows >0) {
    $i=0;
    do { $i++;
    ?>
    <td align="center" valign="top" class="Line"><br />
    <table>
    <tr> <td class="Line"><?php echo $rows['name'];?></td> </tr>
    <tr>
    <td align="center">

    <div id="imageWrap" style="display:none; position:absolute; z-index:10; " align="center">
    <img src="dottedarro.jpg" alt="Main Image" id="mainImage" />
    </div>
    <?php $lnk1='&nbsp;&nbsp;&nbsp;'.'<a href=enquiry.php?id='.$rows['id'].' id=order>Send Enquiry</a>'; ?>
    <?php $lnk= '<a href=enquiry.php?id='. $rows["id"].' class=text12black id=order>Send Enquiry </a>';?>
    <a href="<?php echo $rows['bigimage'];?>" class="thumbnail"><img src="<?php echo $rows['smallimage'];?>" border="4" style="border-color:#CCCCCC" alt="image 2" /></a> </td>
    </tr>
    <tr>
    <td><a href="enquiry.php?id=<?php echo $rows['id'];?>" class="text12black" id="m">Send Enquiry </a></td>
    </tr>
    </table>
    <br /> </td>
    <?php if ($i >= 3) { echo "</tr><tr>";$i=0;} ?>
    <?php
    } while ( $rows = mysql_fetch_assoc($Result));
    }
    ?>
    </tr>
    <tr>
    <td align="center" height="100%" colspan="2">&nbsp;</td>
    </tr>
    </table></td>
    </tr>
    </table></td>
    </tr>
    </table></td>
    </tr>
    </table>
    </div>

    <table width="100%" border="0" cellspacing="1" cellpadding="0">
    <tr></tr>
    </table></td>
    </tr>
    </table></td>
    </tr>
    </table></td>
    </tr>
    </table>

    <!-- <a href="#" class="scrollUpBtn"></a> <a href="#" class="scrollDownBtn"></a>
    !-->


    </td>
    </tr>
    <tr>
    <td colspan="2" valign="top" class="text14white" > <?php include_once("inc_footer.php");?></td>
    </td>
    </tr>
    </table>



    </body>
    </html>
     
    vikaspa, Sep 20, 2012 IP