tallberg Posted November 20, 2006 Share Posted November 20, 2006 I have a problem with a disappearing table. Please can anyone help?When form is submitted the $condition is built from the form $_POST array. if($condition){ $query = "SELECT * FROM plantsdb WHERE $condition"; $dbRecords = mysql_query($query, $dbLocalhost) or die("Problem reading table: " . mysql_error()); $intCount = mysql_num_rows($dbRecords); } else echo "Please select the properties you would like your plant to have";… all the $dbRecords array items are put into other arrays to go through a set of similarity computation… this works fine.Then, the code to display the table. for($i=0; $i<$intCount; $i++) { echo "<form action='" . $_SERVER["PHP_SELF"] . "' method='post'>"; echo "<tr><td>$simArray[$i]</td><td>$descriptionArray[$i]</td><td>$usageArray[$i]</td><td>$idArray[$i]</td><td><input type='submit' name='add' value='add to list' ></td><tr>"; } echo "</table>"; echo "</form>";When the add button is pressed the table disappears. Link to comment https://forums.phpfreaks.com/topic/27867-when-the-button-is-pressed-the-table-disappears/ Share on other sites More sharing options...
glenelkins Posted November 20, 2006 Share Posted November 20, 2006 am not seing the $condition variable being decalared anywhere here? Link to comment https://forums.phpfreaks.com/topic/27867-when-the-button-is-pressed-the-table-disappears/#findComment-127433 Share on other sites More sharing options...
craygo Posted November 20, 2006 Share Posted November 20, 2006 first off you are making a new form everytime you loop. put your form tage before the loop. Also you might want to add some debugging functions to help out till everything works.[code]$dbRecords = mysql_query($query, $dbLocalhost) or die (mysql_error());[/code]Also is would be much easier to echo you results out through a while statement rather then all the arrays, but personal preference i guess.Ray Link to comment https://forums.phpfreaks.com/topic/27867-when-the-button-is-pressed-the-table-disappears/#findComment-127440 Share on other sites More sharing options...
tallberg Posted November 20, 2006 Author Share Posted November 20, 2006 Ive realize what part of the problem is. The $condition may contain a string such as this: The_Group='Annuals'. the value attribute of the hidden feild has its content in quotes. When it reads the first quote mark of The_Group='Annuals' it think it is the end of the value. Does any one know a way out of this.echo "<form action='" . $_SERVER["PHP_SELF"] . "' method='post'>";echo"<input type='hidden' name='condition' value=$condition>"; for($i=0; $i<$intCount; $i++) {echo "<tr><td>$simArray[$i]</td><td>$descriptionArray[$i]</td><td>$usageArray[$i]</td><td>$idArray[$i]</td><td><input type='submit' name='add' value='add' ></td><tr>";}echo "</table>"; echo "</form>"; Link to comment https://forums.phpfreaks.com/topic/27867-when-the-button-is-pressed-the-table-disappears/#findComment-127592 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.