SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Nov 2013
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to return a individual rows using ajax

    Hi,

    I am using jquery ajax with PHP and I would like to return individual rows instead of html. here is my code:

    Code:
    $('#btnShowDetails').click(function(){
        $.ajax({
            url : "get_company_details.php",
            data : 'id=ed23e767-539f-11e3-aef0-74de2b9a31a4',
            type : "post",
            success : function(data)
            {
                $('#lblCompanyName').text(company name from data result);
                $('#lblCompanyWebsite').text(company website from data result);
            }
        });
    });
    and here is my get_company_details.php:

    Code:
    <?php
        include('../includes/php_header.php');
        include($_SESSION["absolute_path"] . '/includes/connect2db.php');
        
        if (!isset($_SESSION["member_loggedOn"])) { exit(header("Location: ../signin")); }
        
        $mysql_query = $mysql_connection->prepare("CALL sp_get_company_details(:param_company_guid)");
        $mysql_query->bindParam(':param_company_guid', $_GET["id"], PDO::PARAM_STR);
        $mysql_query->execute();
    
        $mysql_row_count = $mysql_query->rowCount();
    
        if ($mysql_row_count <= 0) { exit(header("Location: " . $_SESSION["domain_name"] . "home")); }
    
        while ($mysql_row = $mysql_query->fetch())
        {
            $company_id = $mysql_row["company_id"];
            $company_guid = $mysql_row["company_guid"];
            $company_name = $mysql_row["company_name"];
            $company_industry = $mysql_row["industry_name"];
            $company_country = $mysql_row["country_name"];
            $company_region = $mysql_row["region_name"];
            $company_telephone = $mysql_row["company_telephone"];
            $company_fax = $mysql_row["company_fax"];
            $company_website = $mysql_row["company_website"];
            $company_email = $mysql_row["company_email"];
            $about_company = $mysql_row["about_company"];
            $hide_email = $mysql_row["hide_email"];
        }
    ?>

    Thanks,
    <snip/>
    Last edited by Mittineague; Jan 11, 2014 at 16:45.


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
  •