select multiple and array's = no hair left
Posted: Thu Jul 11, 2002 4:38 pm
Found info on select multiple, but then what? I know it's an array but what step do I follow to get my output. Using IPlanet and MySQL.
here is the code.
<form method=\"post\" action=\"pdtest.php\">
<table border=0 cellpadding=5 cellspacing=5>
<tr>
<td rowspan=2><select name=\"sel_server[]\" size=30 multiple>
";
while ($row = mysql_fetch_array($sql_result)) {
$hostname = $row["hostname"];
echo "
<option value=\"$hostname\">$hostname</option>
";
}
echo "
</select></td>
code for the other page:
<?php
// file name: powerdown1.php
//create connection
$connection = mysql_connect("localhost", "root") or die ("couldn't connect to server.");
// select database
$db = mysql_select_db("toolboxdb",$connection) or die ("couldn't connect to database.");
// create sql statement
$sql = "select * from powerdown where hostname = \"$sel_server\"";
// execute SQL query and get result
$sql_result = mysql_query($sql,$connection) or die ("couldn't execute query.");
if (!$sql_result) {
echo "<P>Couldn't get list!";
} else {
echo "
<html>
looked at this for a week and not able to grasp the array part.
Thanks for the help!
here is the code.
<form method=\"post\" action=\"pdtest.php\">
<table border=0 cellpadding=5 cellspacing=5>
<tr>
<td rowspan=2><select name=\"sel_server[]\" size=30 multiple>
";
while ($row = mysql_fetch_array($sql_result)) {
$hostname = $row["hostname"];
echo "
<option value=\"$hostname\">$hostname</option>
";
}
echo "
</select></td>
code for the other page:
<?php
// file name: powerdown1.php
//create connection
$connection = mysql_connect("localhost", "root") or die ("couldn't connect to server.");
// select database
$db = mysql_select_db("toolboxdb",$connection) or die ("couldn't connect to database.");
// create sql statement
$sql = "select * from powerdown where hostname = \"$sel_server\"";
// execute SQL query and get result
$sql_result = mysql_query($sql,$connection) or die ("couldn't execute query.");
if (!$sql_result) {
echo "<P>Couldn't get list!";
} else {
echo "
<html>
looked at this for a week and not able to grasp the array part.
Thanks for the help!