A
Anonymous
Guest
I have the following script that I want to display in my main script with an include() statement. I need the results of the script to be placed into a variable that is later called in an echo statement. I can't seem to get it to fit into my main script. Any help?
I want to call the script in my main script like this...
I have tried many things that result in errors, or only a single insect_order appearing in the select box instead of all of the names available in the DB. Any suggestions?
Code:
<?php
//connect to the database
include ('mysql_connect.php');
//select all of the names of orders available
$get_orders = "select * from insect_order";
$order_names = mysql_query($get_orders, $conn) or die(mysql_error());
// start a select box
echo "<Strong>Select Insect Order</Srong><BR>
<select name=\"insect_orders\" size =\"1\">
<OPTION selected value=\"none\">None</OPTION>";
//display order_names as options in the select box
WHILE($newArray = mysql_fetch_array($order_names)) {
$id = $newArray['orderID'];
$name = $newArray['order_name'];
$option = "<OPTION value = \"$id\">$name</OPTION>";
echo $option;
}
//stop the select box
echo "</SELECT>";
?>
I want to call the script in my main script like this...
Code:
<?php
$select_order_box = include ('select_orders.php');
$display_block = "<h1>Add Insect Family</h1>
<form method=\"POST\" enctype=\"multipart/form-data\"
action=\"$_SERVER[PHP_SELF]\"><P><strong>Family Name:</strong><br>
<input type=\"text\" name=\"family_name\" size=30 maxlength=40>
$select_order_box <P><input type=\"hidden\" name=\"op\" value=\"add\">
<input type=\"submit\" name=\"submit\"
value=\"Add Insect Family\">";
echo $display_block;
?>
I have tried many things that result in errors, or only a single insect_order appearing in the select box instead of all of the names available in the DB. Any suggestions?