Prepared Statements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am just starting to use Prepared Statements and am in a learning curve.

I am working on the code below.  It is for a directory.  This is to select the listing for updating.

How do I tell if there are more than 1 search result?  

Am I correctly retrieving the results, if there is more than 1?  

I want to make a WHILE loop to display the search results for the listing the user is editing.  (You can see where I have started the <ul> ... </ul> ... I want that area in the loop)

Ron


$dbh = new PDO($dsh, $username, $password); 

$stmt = $dbh->prepare("SELECT `reference`, `organization`, `city`, `province_state`, `postal_zip_code`, `country` FROM `ministry_profiles` WHERE ( `reference` = :organization_reference ) OR ( `organization` LIKE %:organization_name% ) OR ( `telephone` LIKE %:organization_phone% ) OR ( `toll_free` LIKE %:organization_toll_free_phone% ) ORDER BY `organization` ASC"); 

$stmt->bindParam(':organization_reference', $organization_reference, PDO::PARAM_STR);
$stmt->bindParam(':organization_name', $organization_name, PDO::PARAM_STR);
$stmt->bindParam(':organization_phone', $organization_phone, PDO::PARAM_STR);
$stmt->bindParam(':organization_toll_free_phone', $organization_phone, PDO::PARAM_STR);

$stmt->execute(); 

$result = $stmt->fetch(PDO::FETCH_ASSOC);

echo "<ul>\r\n";

    $search_result_organization_reference = $result['reference'];
    $search_result_organization = $result['organization'];
    $search_result_city = $result['city'];
    $search_result_province_state = $result['province_state'];
    $search_result_postal_zip_code = $result['postal_zip_code'];
    $search_result_country = $result['country'];

    echo "<li><strong>" . $search_result_organization . "</strong> (Ref: " . $search_result_organization_reference . ")<br />\r\n";
echo $search_result_city . ", " . $search_result_province_state . " " . $search_result_country . " " . $search_result_postal_zip_code . "</li>\r\n";

echo "</ul>\r\n";

The Verse of the Day
âEncouragement from Godâs Wordâ
http://www.TheVerseOfTheDay.info 

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux