Drop List mysql Array
Moderator: General Moderators
Drop List mysql Array
I have been trying to do something for the past 4 days with no luck.
Need help badly.
Here is my situation.
I have a drop list populated by a mysql_query
it will query a table called PACKAGES from it!, it will retrieve 2 columns of data one called [pname] the other called [radius_attributes_high].
for whatever selection is made in the drop list form i need the [pname] and the [radius_attributes_high] sent to another table called CLIENTS and in the clients table the will go under....
[pname] -> [package] and [radius_attributes_high] -> [radius_attributes]
I cant seem to figure out what to do with it, here is my code;
<?PHP
$package_result = mysql_query("SELECT pname, radius_attributes_high FROM packages",$mysql_ID);
echo '<select name="radius_attributes" TABINDEX="18">';
while ($row_item = mysql_fetch_assoc($package_result)){
$attributes = $row_item["radius_attributes_high"];
$pname = $row_item["pname"];
echo "<OPTION value=\"$attributes\">$pname</OPTION>";
}
echo '</SELECT><BR>';
mysql_free_result ($package_result);
?>
$pname is the Name of the PACKAGE and $attributes is the Radius Attributes
What this is meant to do is this;
i have a table PACKAGES to manage and maintain ISP packages and a table CLIENTS to maintain clients the above script is just a portion of a full form the is the part when ADDING a new client you will choose from available packages i need the package name to be placed in the clients account so i know what package he/she has and i also need the attributes that package uses and it be placed into the clients account under the radius_attributes field.
So i you all get what im doing does anyone have suggestions on what i can do to send these two values from a SELECT field?
Need help badly.
Here is my situation.
I have a drop list populated by a mysql_query
it will query a table called PACKAGES from it!, it will retrieve 2 columns of data one called [pname] the other called [radius_attributes_high].
for whatever selection is made in the drop list form i need the [pname] and the [radius_attributes_high] sent to another table called CLIENTS and in the clients table the will go under....
[pname] -> [package] and [radius_attributes_high] -> [radius_attributes]
I cant seem to figure out what to do with it, here is my code;
<?PHP
$package_result = mysql_query("SELECT pname, radius_attributes_high FROM packages",$mysql_ID);
echo '<select name="radius_attributes" TABINDEX="18">';
while ($row_item = mysql_fetch_assoc($package_result)){
$attributes = $row_item["radius_attributes_high"];
$pname = $row_item["pname"];
echo "<OPTION value=\"$attributes\">$pname</OPTION>";
}
echo '</SELECT><BR>';
mysql_free_result ($package_result);
?>
$pname is the Name of the PACKAGE and $attributes is the Radius Attributes
What this is meant to do is this;
i have a table PACKAGES to manage and maintain ISP packages and a table CLIENTS to maintain clients the above script is just a portion of a full form the is the part when ADDING a new client you will choose from available packages i need the package name to be placed in the clients account so i know what package he/she has and i also need the attributes that package uses and it be placed into the clients account under the radius_attributes field.
So i you all get what im doing does anyone have suggestions on what i can do to send these two values from a SELECT field?
Try something along the lines of:
<?PHP
echo "<select name='radius_attributes' TABINDEX='18'>";
$query = "SELECT pname, radius_attributes_high FROM packages",$mysql_ID;
$result = mysql_query($query) or die("Error!");
while (true)
{
$row_item = mysql_fetch_assoc($result);
if ($row_item == false) break;
$attributes = $row_item["radius_attributes_high"];
$pname = $row_item["pname"];
echo "<OPTION value='$attributes'>$pname</OPTION>";
}
echo "</SELECT><BR>";
mysql_close($query);
?>
Regards
Joe
<?PHP
echo "<select name='radius_attributes' TABINDEX='18'>";
$query = "SELECT pname, radius_attributes_high FROM packages",$mysql_ID;
$result = mysql_query($query) or die("Error!");
while (true)
{
$row_item = mysql_fetch_assoc($result);
if ($row_item == false) break;
$attributes = $row_item["radius_attributes_high"];
$pname = $row_item["pname"];
echo "<OPTION value='$attributes'>$pname</OPTION>";
}
echo "</SELECT><BR>";
mysql_close($query);
?>
Regards
Joe
Thanks alot for the replies.
BUT! ........
You aint gettin what im asking.
Let me ask again in a different way.
A DROP LIST! ....
TWO VARIABLES ....
FOR A SELECTION SEND TWO VARIABLES FROM THAT DROP LIST IN TWO DIFFERENT PLACES.
P.S.
if ya put $variable1 and $variable2 between the VALUE tag of an OPTION the dam things are going to go to the same place E.G. (((( THE NAME AS SET BY THE SELECT TAG ))))
ARRRRRRRRG!!!!!!!!
Don't mind me guy's and gals it's just that i've been on so many forums in the past week and i keep getting the same every where nobody understands what my question is.
Thanks
BUT! ........
You aint gettin what im asking.
Let me ask again in a different way.
A DROP LIST! ....
TWO VARIABLES ....
FOR A SELECTION SEND TWO VARIABLES FROM THAT DROP LIST IN TWO DIFFERENT PLACES.
P.S.
if ya put $variable1 and $variable2 between the VALUE tag of an OPTION the dam things are going to go to the same place E.G. (((( THE NAME AS SET BY THE SELECT TAG ))))
ARRRRRRRRG!!!!!!!!
Don't mind me guy's and gals it's just that i've been on so many forums in the past week and i keep getting the same every where nobody understands what my question is.
Thanks
how about concatenate two values using a special separator to a single value then separate and retrieve them in the client table page:
some thing:
echo "<OPTION value=\"$attributes . "XXX" . $pname . \">$pname</OPTION>";
in the client page:
arr = explode("XXX", $HTTP_POST_VAR['attribute_value']);
list ($attr, $pname) = each arr;
etc. ...
some thing:
echo "<OPTION value=\"$attributes . "XXX" . $pname . \">$pname</OPTION>";
in the client page:
arr = explode("XXX", $HTTP_POST_VAR['attribute_value']);
list ($attr, $pname) = each arr;
etc. ...
OK...evanz wrote:how about concatenate two values using a special separator to a single value then separate and retrieve them in the client table page:
some thing:
echo "<OPTION value="$attributes . "XXX" . $pname . ">$pname</OPTION>";
in the client page:
arr = explode("XXX", $HTTP_POST_VAR['attribute_value']);
list ($attr, $pname) = each arr;
etc. ...
Hmm...
I'll try this, im still trying to see the logic in your example.
Never the less i'll see if i can make it work if i do i'll get back you and post my results; ok?
Thanks a mill guys and gals
Ok i tried this but it dont work it gives an error right away
Parse error: parse error in /home/xxxxxxxxxxx.xxx/temp/index.php on line 300
this
<OPTION value=\"$attributes . "XXX" . $pname . \">$pname</OPTION>
the . dot cause an error in my scripts
have any ideas?
Maybe i should post my entire page?
Yes? No?
what do ya think?
Parse error: parse error in /home/xxxxxxxxxxx.xxx/temp/index.php on line 300
this
<OPTION value=\"$attributes . "XXX" . $pname . \">$pname</OPTION>
the . dot cause an error in my scripts
have any ideas?
Maybe i should post my entire page?
Yes? No?
what do ya think?
I always try to use the "." as little as possible, hence my version would look.recsx wrote: <OPTION value="$attributes . "XXX" . $pname . ">$pname</OPTION>
Code: Select all
$string_to_echo = "<option value = '$attributesXXX$pname'>$pname</option>";Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
HOORAY!!!!!!!!!!!!!!!
it worked!!!!!!!
this is what i did
Here is my drop list
<?PHP
// Populate a Drop List for available packages
$package_result = mysql_query("SELECT pname, radius_attributes_high FROM packages",$mysql_ID);
echo '<select name="package_select" TABINDEX="18"><OPTION>';
echo $myrow["package"];
echo "</OPTION>";
while ($row_item = mysql_fetch_assoc($package_result)){
$attributes = $row_item["radius_attributes_high"];
$pname = $row_item["pname"];
echo "<OPTION value=\"$attributes" . "DIVIDE" . "$pname\">$pname</OPTION>";
}
if(mysql_num_rows($package_result) == "0"){
$no_packages = "<OPTION value=\"#No Attributes" . "DIVIDE" . "No Package\">No Packages Made</OPTION>";
}
echo "$no_packages";
echo '</SELECT><BR>';
mysql_free_result ($package_result);
// End Populate Drop List
?>
once submited my form is sent via $PHP_SELF
and
if (submit)
start doing my update client
but before the mysql query i entered the explode like this
// Package Drop List Explode and Seperate the Attributes from the Package Name
$selected_package = $_POST['package_select'];
$xx = explode("DIVIDE", $selected_package);
$radius_attributes = $xx[0];
$package = $xx[1];
// End Explode
and voila it works as it should
Man you guys and gals are life savers
i had to go to php.net for the right syntax of the explode statement and a few minutes of reading i had it down pat.
Oh! what i can do with this command is behond my brain.
Thanks a bunch.
it worked!!!!!!!
this is what i did
Here is my drop list
<?PHP
// Populate a Drop List for available packages
$package_result = mysql_query("SELECT pname, radius_attributes_high FROM packages",$mysql_ID);
echo '<select name="package_select" TABINDEX="18"><OPTION>';
echo $myrow["package"];
echo "</OPTION>";
while ($row_item = mysql_fetch_assoc($package_result)){
$attributes = $row_item["radius_attributes_high"];
$pname = $row_item["pname"];
echo "<OPTION value=\"$attributes" . "DIVIDE" . "$pname\">$pname</OPTION>";
}
if(mysql_num_rows($package_result) == "0"){
$no_packages = "<OPTION value=\"#No Attributes" . "DIVIDE" . "No Package\">No Packages Made</OPTION>";
}
echo "$no_packages";
echo '</SELECT><BR>';
mysql_free_result ($package_result);
// End Populate Drop List
?>
once submited my form is sent via $PHP_SELF
and
if (submit)
start doing my update client
but before the mysql query i entered the explode like this
// Package Drop List Explode and Seperate the Attributes from the Package Name
$selected_package = $_POST['package_select'];
$xx = explode("DIVIDE", $selected_package);
$radius_attributes = $xx[0];
$package = $xx[1];
// End Explode
and voila it works as it should
Man you guys and gals are life savers
i had to go to php.net for the right syntax of the explode statement and a few minutes of reading i had it down pat.
Oh! what i can do with this command is behond my brain.
Thanks a bunch.