SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2010
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to post value to another page and get back the data without refresh

    Hello all. I have many tags. I want click each tag, then post/get the tag's value to another page.

    In another page, received the values and make a mysql query. Then return the resalt data to the first page(do not make an iframe).

    I think jquery post and load may be can do that (but have no idea how to combine two functiton). Or maybe there have any other way. Thanks.

    here is my code

    products.php

    HTML Code:
    <a href="data.php?get=hml03">model:hml03</a> 
    <a href="data.php?get=hml04">model:hml04</a> 
    <a href="data.php?get=hml05">model:hml05</a><!--post value from products.php--> 
    ...<!--many other tags --> 
    <div class="show_data"></div><!-- get the data back show in here without refresh the page.

    data.php

    Code:
    <div id="data">
    <?php
    $result = mysql_query("SELECT id,name,details,add_date,model FROM ctw_products WHERE (MATCH (name,details,model) AGAINST ('+$_GET['get']' IN BOOLEAN MODE) Order By add_date DESC LIMIT 20 "); // get value with a mysql query 
    while ($row = mysql_fetch_array($result))
    {
    echo '<div class="name">'.$row['name'].'</div>';
    echo '<div class="model">'.$row['model'].'</div>'; 
    echo '<div class="details">'.$row['details'].'</div>';// how to return this part of datas back to products.php 
    }
    ?>
    </div>

  2. #2
    SitePoint Enthusiast
    Join Date
    Sep 2010
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should look into ajax. It's very simple to use and it will do pretty much exactly what you're looking for.

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    The best reference that I've found for learning how to write your own ajax code is Bulletproof Ajax
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  4. #4
    SitePoint Zealot
    Join Date
    Aug 2010
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, but it will cost more time to read a book. If there is a simple demo, I think I can quickly learn...

  5. #5
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by youlichika View Post
    Thanks, but it will cost more time to read a book. If there is a simple demo, I think I can quickly learn...
    If you go to the web page for Bulletproof Ajax you will see that all of the code and examples are freely provided too.

    Note though that there are several examples of each type, as they work their way through different techniques to achieve more flexible results.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •