| How to call results in Wordpress page
|
Jim123

msg:4187530 | 7:11 am on Aug 16, 2010 (gmt 0) | 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="test";
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 Twentyten 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 Iīm a bit stuck at the moment. Anyone with suggestions? Thanks
|
|