Hi,
I have being doing some php code for the very first time using wordpress as a template, basicaly what i want the prog to do is get data from a drop down menu, which i have populated with data from a MSQL db. pass it to a button (on the same page) and it to run a SQL statemment and populate the data in a table.
What i am having problems with is to get the data to the botton where it will execute on the same page.
Code below:[php]<?php
$dbhost = 'it.test.com';
$dbuser = 'audit';
$dbpass = 'audit';
$conn = mysql_connect($ dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
$dbname = 'WinAudi2';
mysql_select_db ($dbname);
$result = mysql_query( "SELECT DISTINCT Computer FROM $dbname" ) or die("SELECT Error: ".mysql_error() );
$num_rows = mysql_num_rows( $result);
print "There are $num_rows records.<P>";
print "<table width=100 border=1>\n";
print "<select>";
while ($get_info = mysql_fetch_row ($result)){
foreach ($get_info as $field)
print "<option>$field </option>\n";
}
print "</select></table>\n";
?>
</body>
</html>
[/php]
Please read the Posting Guidelines, its link is on the top of this forum. Especially the part about enclosing code within the appropriate code tags. - moderator
I have being doing some php code for the very first time using wordpress as a template, basicaly what i want the prog to do is get data from a drop down menu, which i have populated with data from a MSQL db. pass it to a button (on the same page) and it to run a SQL statemment and populate the data in a table.
What i am having problems with is to get the data to the botton where it will execute on the same page.
Code below:[php]<?php
$dbhost = 'it.test.com';
$dbuser = 'audit';
$dbpass = 'audit';
$conn = mysql_connect($ dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
$dbname = 'WinAudi2';
mysql_select_db ($dbname);
$result = mysql_query( "SELECT DISTINCT Computer FROM $dbname" ) or die("SELECT Error: ".mysql_error() );
$num_rows = mysql_num_rows( $result);
print "There are $num_rows records.<P>";
print "<table width=100 border=1>\n";
print "<select>";
while ($get_info = mysql_fetch_row ($result)){
foreach ($get_info as $field)
print "<option>$field </option>\n";
}
print "</select></table>\n";
?>
</body>
</html>
[/php]
Please read the Posting Guidelines, its link is on the top of this forum. Especially the part about enclosing code within the appropriate code tags. - moderator
Comment