• Really stupid, but I can′t figure it out.

    I have two files. One is the form

    <div id="container">
    <div id="content" role="main">
    
    <form action="/vitamine/wp-content/themes/twentyten/insert.php" method="post">
    Value1: <input type="text" name="value1"><br>
    <input type="Submit">
    </form>
    
    </div><!-- #content -->
    </div><!-- #container -->
    
    <?php get_footer(); ?>

    and the other one is insert.php to get the results

    <?php
    $username="root";
    $password="";
    $database="vitaminen";
    
    mysql_connect(localhost,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    $query="SELECT Shrt_Desc, Vit_D_mcg, Water, Energ_Kcal, Protein, Lipid_Tot, Carbohydrt FROM abbrev WHERE Shrt_Desc LIKE '%".mysql_real_escape_string($_POST['value1'])."%' ORDER BY Vit_D_mcg DESC ";
    $result=mysql_query($query) or die("could not execute query: " . mysql_error());
    while ($row=mysql_fetch_array($result)) {
    $results .= '<tr>
    <td>' . $row['Shrt_Desc'] . '</td>
    <td>' . $row['Vit_D_mcg'] . '</td>
    <td>' . $row['Water'] . '</td>
    <td>' . $row['Energ_Kcal'] . '</td>
    <td>' . $row['Protein'] . '</td>
    <td>' . $row['Lipid_Tot'] . '</td>
    <td>' . $row['Carbohydrt'] . '</td>
    </tr>';
    }
    mysql_close();
    //
    if ($results) {
    echo "<table border=\"1\" align=\"center\" cellpadding=\"2\" cellspacing=\"2\">
    <tr><td>NAME</td><td>Vit D mcg</td><td>Water</td><td>Energy</td><td>Protein</td><td>Fat</td><td>Carbohydrate</td></tr>
    $results
    </table>
    ";
    }
    else { echo "<p>No results were found with that search.</p>"; }
    ?>

    I want the results showing up in the WordPress Twenty Ten theme, but whatever I do, I can′t get further than having the results on a blank page.

    I tried

    <?php
    $username="root";
    $password="";
    $database="vitaminen";
    
    mysql_connect(localhost,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    $query="SELECT Shrt_Desc, Vit_D_mcg, Water, Energ_Kcal, Protein, Lipid_Tot, Carbohydrt FROM abbrev WHERE Shrt_Desc LIKE '%".mysql_real_escape_string($_POST['value1'])."%' ORDER BY Vit_D_mcg DESC ";
    $result=mysql_query($query) or die("could not execute query: " . mysql_error());
    while ($row=mysql_fetch_array($result)) {
    $results .= '<tr>
    <td>' . $row['Shrt_Desc'] . '</td>
    <td>' . $row['Vit_D_mcg'] . '</td>
    <td>' . $row['Water'] . '</td>
    <td>' . $row['Energ_Kcal'] . '</td>
    <td>' . $row['Protein'] . '</td>
    <td>' . $row['Lipid_Tot'] . '</td>
    <td>' . $row['Carbohydrt'] . '</td>
    </tr>';
    }
    mysql_close();
    //
    if ($results) {
    
    get_header(); ?>
    
    <div id="container">
    <div id="content" role="main">
    
    <?php
    echo "<table border=\"1\" align=\"center\" cellpadding=\"2\" cellspacing=\"2\">
    <tr><td>NAME</td><td>Vit D mcg</td><td>Water</td><td>Energy</td><td>Protein</td><td>Fat</td><td>Carbohydrate</td></tr>
    $results
    </table>
    ";
    }
    else { echo "<p>No results were found with that search.</p>"; }
    ?>
    
    </div><!-- #content -->
    </div><!-- #container -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    but that gives me this error:
    Fatal error: Call to undefined function get_header() in C:\xampp\htdocs\test\wp-content\themes\twentyten\insert.php

    How can I embed the results in the Twenty Ten layout?
    Thanks

  • The topic ‘Call database results into loop Twenty Ten’ is closed to new replies.