• Hi I am 70 and new to PHP. I have been struggling for a month to find my problem retrieving database info from a search form. I created the DTB and the search form with 2 criteria:
    “Choose one or more services in your area zip code.
    On the form I created a drop down menu of about 60 available zip codes (choose one), and a multiple-choice checkbox with 20 specialties.( choose as many as needed.)

    when using this basic code my result find the database OK, but returns all DTB listings regardless of selection (or no selection at all) which is normal.

    <?php
    $result = mysql_query("SELECT * FROM wp_uvmj_participants_database", $db)

    That only proves me the DTB is working but of course, I need to get ONLY the selected result from the request on the form.

    When adding <WHERE> to this string my result then gives me a blank page (only showing the HTML sentence :In construction etc etc..”)
    WHAT AM I DOING WRONG???
    I am using
    PHP version 5.4.24
    MySQL version 5.5.40-36.1-log
    here is the entire search.PHP

    <?php
     $db = mysql_connect("localhost","<em>my_username</em>","<em>my_password***</em>");
     if (!$db) {
     die("Database connection failed miserably: " . mysql_error());
     }
     $db_select = mysql_select_db("<em>mydtb-name</em>",$db);
     if (!$db_select) {
     die("Database selection also failed miserably: " . mysql_error());
     }
    
    ?>
    <html>
     <head>
     <title>members</title>
     </head>
     <body>
     <em>IN CONSTRUCTION. TRY OUT ONLY<br/>
     This is listing of available specialty or specialties offering services in your own zip code</em>
    <div class="cssstyle">
    
    <?php
    array(10, 12);
     //fetch and make it a comma separated string using implode() php string function
     $csvSearch = implode(',', $_POST["specialty"]);
     $qry=mysql_query("SELECT * FROM participants_database WHERE specialty(dor, '$csvSearch')");
    $result = mysql_query("SELECT * FROM participants_database WHERE zip='abcd123' AND specialty='abc123'", $db);
     if (!$result) {
     die("Database query failed: " . mysql_error());
     }
     while ($row = mysql_fetch_array($result)) {
        echo "<h2>".$row['company']."</h2>";
        echo "<p>".$row['first_name']." - ".$row['specialty']."</p>";
        echo "<p>".$row['sub_category']."</p>";
        echo "<p>".$row['area']."</p>";
        echo "<p>".$row['photo']."</p>";
        echo "<p>".$row['bio']."</p>";
    }
    ?>
    </div>
     </body>
    </html>
    
    <?php
     mysql_close($db);
    ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘mysql query "SELECT" from*** WHERE*** gives me a blank result’ is closed to new replies.