homepage Welcome to WebmasterWorld Guest from 54.145.183.126
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Passing and getting variables through an array and $ POST
ModernMerlin



 
Msg#: 4438930 posted 10:24 pm on Apr 9, 2012 (gmt 0)

I am trying to build a form in a while loop. It has check boxes and and combo boxes.


<form name="Getting_Spells2" method="post" action="free-app3.php">
<?php
//Including the connection information
include "config.php";

//connect to the mysql server
$link = mysql_connect($server, $db_user, $db_pass) or die("Could not connect to MySQL");

//select the database
mysql_select_db($database) or die ("Could not select database");

//Put the result into an array
$result = mysql_query ("SELECT DISTINCT spell_name FROM spells WHERE spell_class = '".$class."' AND spec = '".$spec."' AND spell_level BETWEEN '".$level_low."' AND '".$level."'") or die('Error getting array form spells table '.mysql_error ());

while($row = mysql_fetch_array($result))
{
$spell_id=$row["spell_id"];
$spell_name=$row["spell_name"];
$class=$row["spell_class"];
$level=$row["spell_level"];
$knowledge=$row["spell_knowledge"];
$mindmg=$row["min_dmg"];
$maxdmg=$row["max_dmg"];
$mindot=$row["min_dot"];
$maxdot=$row["max_dot"];
$dot_ticks=$row["dot_ticks"];
$cast_time=$row["cast_time"];
$duration=$row["duration"];
$recovery=$row["recovery"];
$recast=$row["recast"];
$triggers=$row["triggers"];
$avg_dmg=$row["avg_dmg"];
$instant_time=$row["instant_time"];
$total_cast_time=$row["total_cast_time"];
$instant_dps=$row["instant_dps"];
$dps=$row["dps"];
$spec=$row["spec"];


echo "<input type=\"checkbox\" name=\"spell_name2[]\" value=\"".$spell_name."\"&nbsp;&nbsp;&nbsp;>";
echo $spell_name."&nbsp;&nbsp;&nbsp;". $class ."<BR>";

//Including the connection information
include "config.php";

//connect to the mysql server
$link = mysql_connect($server, $db_user, $db_pass) or die("Could not connect to MySQL");

//select the database
mysql_select_db($database) or die ("Could not select database");

//Get the spell knowledge for the row
$query2 = mysql_query ("SELECT knowledge FROM spell_knowledge ORDER By knowledge_id ASC") or die(mysql_error());

//Put the result into an array
$result2 = mysql_fetch_array($query2);

if ($result2) {
$rowno = 0;

echo("<select name=\"knowledge2[]\" size=\"1\" id=\"knowledge2[]\"><BR><BR>");

while ($row = mysql_fetch_assoc($query2)) {

$rowno++;

foreach($row as $_k=>$_v) {

echo("<option value=\"" .$_v. "\">" .$_v. "");

}

}
echo("</select>");
}
else {
# Print error
echo "<b>Query2 failed: Knowledge</b><br>".mysql_error();
}
echo "<br />";


}
?>
<input type="submit" name="Submit" value="Submit">
</form><br>


When I go to the next page it gives me the correct values for the checkboxes but gives me ALL of the values for the comboboxes not just the ones that were checked.

How do I get it to give me just the values form the comboboxes for the rows that were checked?

Any help would be greatly appreciated!

MM

 

cffrost2

5+ Year Member



 
Msg#: 4438930 posted 12:28 pm on Apr 10, 2012 (gmt 0)

Should you have a WHERE statement included in this?


$query2 = mysql_query ("SELECT knowledge FROM spell_knowledge WHERE column = checkedbox_value ORDER By knowledge_id ASC") or die(mysql_error());

ModernMerlin



 
Msg#: 4438930 posted 4:11 am on Apr 11, 2012 (gmt 0)

No, But I figured out a way around it. Thank you for trying :) Off to tackle my next hurdle!

MM

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved