Bumped by Community user
    Bumped by Community user
3 Fix grammar and improve code indentation
source | link

Using AJAX to run sqlSQL statement and populate dropdown

I am trying to create a search where the user selectselects two different bitbits of data from databasesthe database and it themthen prints some results that meet requirements. I know I need to use ajaxAJAX, or something similar, but I have little idea how I should be doing it. The first drop downdropdown box works fine, as that doesn't depend on anything here. Here is the code for that.:

<select name="raceTrack2" onchange="">
       <?php $postids = $wpdb->get_col("
  <?php
      SELECT trackName  
    $postids = $wpdb->get_col("SELECT trackName FROM " . $trackTableName . ";");
";
    ");        foreach ($postids as $value) { 
    foreach ($postids as $value) {
        echo '<option>' . $value . '</option>' ;
 
            }
            ?>
        </select>

That works fine now the. The next step I need to do is where it startstarts to get complicated. Now I need to take the value of the first selection box and add it into the sqlSQL query of the next one, then run that query when the first selection box changes using onchangeonchange.

<select name="raceDate">
        <?php $postids2 = $wpdb->get_col("
        SELECT DISTINCT raceDate  
  $postids2 = $wpdb->get_col("SELECT DISTINCT raceDate  FROM " . $tableName . " 
        WHERE trackName = '" . $track . "';");
"';
        ");
    foreach ($postids2 as $value2) {
                echo  $value2  ;        
            }
            ?>
        </select>   

Then I need to take the value of both of these dropdowns and use itthem in this final query to display the results.:

$postids = $wpdb->get_results("SELECT"
    SELECT driverName, driverClass, driverPosition 
    FROM " . $tableName . "WHERE"
    WHERE trackName = '" . $track . "' AND raceDate = " . $date . ";"";
");
 
            foreach ($postids as $value) {
                echo '<tr valign="top">';
                echo '<td>' . $value->driverName . '</td>';
                echo '<td>' . $value->driverClass . '</td>';
                echo '<td>' . $value->driverPosition . '</td>'; 
                echo '</tr>';
            } 
             }

Using AJAX to run sql statement and populate dropdown

I am trying to create a search where the user select two different bit of data from databases and it them prints some results that meet requirements. I know I need to use ajax or something similar but I have little idea how I should be doing it. The first drop down box works fine as that doesn't depend on anything here is the code for that.

<select name="raceTrack2" onchange="">
            <?php
            $postids = $wpdb->get_col("SELECT trackName FROM " . $trackTableName . ";");

            foreach ($postids as $value) {
                echo '<option>' . $value . '</option>' ;
 
            }
            ?>
        </select>

That works fine now the next step I need to do is where it start to get complicated I need to take the value of the first selection box and add it into the sql query of the next one then run that query when the first selection box changes using onchange.

<select name="raceDate">
        <?php 
            $postids2 = $wpdb->get_col("SELECT DISTINCT raceDate FROM " . $tableName . " WHERE trackName = '" . $track . "';");

            foreach ($postids2 as $value2) {
                echo  $value2  ;        
            }
            ?>
        </select>   

Then I need to take the value of both of these dropdowns and use it in this final query to display the results.

$postids = $wpdb->get_results("SELECT driverName, driverClass, driverPosition FROM " . $tableName . "WHERE trackName = '" . $track . "' AND raceDate = " . $date . ";");
 
            foreach ($postids as $value) {
                echo '<tr valign="top">';
                echo '<td>' . $value->driverName . '</td>';
                echo '<td>' . $value->driverClass . '</td>';
                echo '<td>' . $value->driverPosition . '</td>'; 
                echo '</tr>';
            } 
             }

Using AJAX to run SQL statement and populate dropdown

I am trying to create a search where the user selects two different bits of data from the database and it then prints some results that meet requirements. I know I need to use AJAX, or something similar, but I have little idea how I should be doing it. The first dropdown box works fine, as that doesn't depend on anything. Here is the code for that:

<select name="raceTrack2" onchange="">
    <?php $postids = $wpdb->get_col("
        SELECT trackName  
        FROM " . $trackTableName . ";
    ");             
    foreach ($postids as $value) {
        echo '<option>' . $value . '</option>' ;
    } ?>
</select>

That works fine. The next step is where it starts to get complicated. Now I need to take the value of the first selection box and add it into the SQL query of the next one, then run that query when the first selection box changes using onchange.

<select name="raceDate">
    <?php $postids2 = $wpdb->get_col("
        SELECT DISTINCT raceDate  
        FROM " . $tableName . " 
        WHERE trackName = '" . $track . "';
    ");
    foreach ($postids2 as $value2) {
        echo  $value2  ;        
    } ?>
</select>

Then I need to take the value of both of these dropdowns and use them in this final query to display the results:

$postids = $wpdb->get_results("
    SELECT driverName, driverClass, driverPosition 
    FROM " . $tableName . "
    WHERE trackName = '" . $track . "' AND raceDate = " . $date . ";
");
foreach ($postids as $value) {
    echo '<tr valign="top">';
    echo '<td>' . $value->driverName . '</td>';
    echo '<td>' . $value->driverClass . '</td>';
    echo '<td>' . $value->driverPosition . '</td>'; 
    echo '</tr>';
}
2 Grammar corrections
source | link

using Using AJAX to run sql statement and populate dropdown

I am trying to create a search where the user select two different bit of data from databases and it them prints some results that meet requirements. I know I need to use ajax or something similar but I have little idea how I should be doing it. The first drop down box works fine as that doesn't depend on anything here is the code for that.

<select name="raceTrack2" onchange="">
            <?php
            $postids = $wpdb->get_col("SELECT trackName FROM " . $trackTableName . ";");

            foreach ($postids as $value) {
                echo '<option>' . $value . '</option>' ;

            }
            ?>
        </select>

That works fine now the next step I need to do is where it start to get complicated I need to take the value of the first selection box and add it into the sql query of the next one then run that query when the first selection box changes using onchange.

<select name="raceDate">
        <?php 
            $postids2 = $wpdb->get_col("SELECT DISTINCT raceDate FROM " . $tableName . " WHERE trackName = '" . $track . "';");

            foreach ($postids2 as $value2) {
                echo  $value2  ;        
            }
            ?>
        </select>   

Then I need to take the value of both of these dropdowns and use it in this final query to display the results.

$postids = $wpdb->get_results("SELECT driverName, driverClass, driverPosition FROM " . $tableName . "WHERE trackName = '" . $track . "' AND raceDate = " . $date . ";");

            foreach ($postids as $value) {
                echo '<tr valign="top">';
                echo '<td>' . $value->driverName . '</td>';
                echo '<td>' . $value->driverClass . '</td>';
                echo '<td>' . $value->driverPosition . '</td>'; 
                echo '</tr>';
            } 
             }

Any helpsuggestions would be appreciated.

using AJAX to run sql statement and populate dropdown

I am trying to create a search where the user select two different bit of data from databases and it them prints some results that meet requirements. I know I need to use ajax or something similar but I have little idea how I should be doing it. The first drop down box works fine as that doesn't depend on anything here is the code for that.

<select name="raceTrack2" onchange="">
            <?php
            $postids = $wpdb->get_col("SELECT trackName FROM " . $trackTableName . ";");

            foreach ($postids as $value) {
                echo '<option>' . $value . '</option>' ;

            }
            ?>
        </select>

That works fine now the next step I need to do is where it start to get complicated I need to take the value of the first selection box and add it into the sql query of the next one then run that query when the first selection box changes using onchange.

<select name="raceDate">
        <?php 
            $postids2 = $wpdb->get_col("SELECT DISTINCT raceDate FROM " . $tableName . " WHERE trackName = '" . $track . "';");

            foreach ($postids2 as $value2) {
                echo  $value2  ;        
            }
            ?>
        </select>   

Then I need to take the value of both of these dropdowns and use it in this final query to display the results.

$postids = $wpdb->get_results("SELECT driverName, driverClass, driverPosition FROM " . $tableName . "WHERE trackName = '" . $track . "' AND raceDate = " . $date . ";");

            foreach ($postids as $value) {
                echo '<tr valign="top">';
                echo '<td>' . $value->driverName . '</td>';
                echo '<td>' . $value->driverClass . '</td>';
                echo '<td>' . $value->driverPosition . '</td>'; 
                echo '</tr>';
            } 
             }

Any help would be appreciated.

Using AJAX to run sql statement and populate dropdown

I am trying to create a search where the user select two different bit of data from databases and it them prints some results that meet requirements. I know I need to use ajax or something similar but I have little idea how I should be doing it. The first drop down box works fine as that doesn't depend on anything here is the code for that.

<select name="raceTrack2" onchange="">
            <?php
            $postids = $wpdb->get_col("SELECT trackName FROM " . $trackTableName . ";");

            foreach ($postids as $value) {
                echo '<option>' . $value . '</option>' ;

            }
            ?>
        </select>

That works fine now the next step I need to do is where it start to get complicated I need to take the value of the first selection box and add it into the sql query of the next one then run that query when the first selection box changes using onchange.

<select name="raceDate">
        <?php 
            $postids2 = $wpdb->get_col("SELECT DISTINCT raceDate FROM " . $tableName . " WHERE trackName = '" . $track . "';");

            foreach ($postids2 as $value2) {
                echo  $value2  ;        
            }
            ?>
        </select>   

Then I need to take the value of both of these dropdowns and use it in this final query to display the results.

$postids = $wpdb->get_results("SELECT driverName, driverClass, driverPosition FROM " . $tableName . "WHERE trackName = '" . $track . "' AND raceDate = " . $date . ";");

            foreach ($postids as $value) {
                echo '<tr valign="top">';
                echo '<td>' . $value->driverName . '</td>';
                echo '<td>' . $value->driverClass . '</td>';
                echo '<td>' . $value->driverPosition . '</td>'; 
                echo '</tr>';
            } 
             }

Any suggestions would be appreciated.

1
source | link

using AJAX to run sql statement and populate dropdown

I am trying to create a search where the user select two different bit of data from databases and it them prints some results that meet requirements. I know I need to use ajax or something similar but I have little idea how I should be doing it. The first drop down box works fine as that doesn't depend on anything here is the code for that.

<select name="raceTrack2" onchange="">
            <?php
            $postids = $wpdb->get_col("SELECT trackName FROM " . $trackTableName . ";");

            foreach ($postids as $value) {
                echo '<option>' . $value . '</option>' ;

            }
            ?>
        </select>

That works fine now the next step I need to do is where it start to get complicated I need to take the value of the first selection box and add it into the sql query of the next one then run that query when the first selection box changes using onchange.

<select name="raceDate">
        <?php 
            $postids2 = $wpdb->get_col("SELECT DISTINCT raceDate FROM " . $tableName . " WHERE trackName = '" . $track . "';");

            foreach ($postids2 as $value2) {
                echo  $value2  ;        
            }
            ?>
        </select>   

Then I need to take the value of both of these dropdowns and use it in this final query to display the results.

$postids = $wpdb->get_results("SELECT driverName, driverClass, driverPosition FROM " . $tableName . "WHERE trackName = '" . $track . "' AND raceDate = " . $date . ";");

            foreach ($postids as $value) {
                echo '<tr valign="top">';
                echo '<td>' . $value->driverName . '</td>';
                echo '<td>' . $value->driverClass . '</td>';
                echo '<td>' . $value->driverPosition . '</td>'; 
                echo '</tr>';
            } 
             }

Any help would be appreciated.