Thundarfoot Posted January 20, 2008 Share Posted January 20, 2008 I am a noob, having trouble with a script I am making. A drop down select form, and a table output. The Problem is on page load, the first time a user looks at the page all records are displayed, which can take a long time to load. I would like to not populate the table output until user clicks the submit button, but any fix is welcome I have included the script code and appreciate your help. <?php require_once('../Connections/Lw.php'); ?> <?php //Database Class Connect mysql_select_db($database_Lw, $Lw); $query_Class = "SELECT `Class` FROM class_list ORDER BY id ASC"; $Class = mysql_query($query_Class, $Lw) or die(mysql_error()); $row_Class = mysql_fetch_assoc($Class); $totalRows_Class = mysql_num_rows($Class); //Database Cards Connect $name = $_POST['select']; mysql_select_db($database_Lw, $Lw); $query_Cards = "SELECT Name, `Class`, Drops, Details FROM skill_cards WHERE skill_cards.`Class` LIKE '$name%' ORDER BY Name ASC"; $Cards = mysql_query($query_Cards, $Lw) or die(mysql_error()); $row_Cards = mysql_fetch_assoc($Cards); $totalRows_Cards = mysql_num_rows($Cards); <body> <form id="form1" name="form1" method="post" action=""> <label>Class <select name="select"> <option value="">ALL</option> <?php do { ?> <option value="<?php echo $row_Class['Class']?>"><?php echo $row_Class['Class']?></option> <?php } while ($row_Class = mysql_fetch_assoc($Class)); $rows = mysql_num_rows($Class); if($rows > 0) { mysql_data_seek($Class, 0); $row_Class = mysql_fetch_assoc($Class); } ?> </select> </label> <input type="submit" name="submit" value="submit"> </form> <table border="1" cellpadding="5" cellspacing="5"> <tr> <td>Name</td> <td>Class</td> <td>Drops</td> <td>Details</td> </tr> <?php do { ?> <tr> <td><?php echo $row_Cards['Name']; ?></td> <td><?php echo $row_Cards['Class']; ?></td> <td><?php echo $row_Cards['Drops']; ?></td> <td><?php echo $row_Cards['Details']; ?></td> </tr> <?php } while ($row_Cards = mysql_fetch_assoc($Cards)); ?> </table> <br /> </body> </html> <?php mysql_free_result($Class); mysql_free_result($Cards); ?> Quote Link to comment https://forums.phpfreaks.com/topic/86959-solved-noob-finishing-touches-on-drop-down-form-ty/ Share on other sites More sharing options...
revraz Posted January 20, 2008 Share Posted January 20, 2008 Add a IF statement that checks to see if it was submitted. If it has then you can display the records, if not, then it doesn't. Quote Link to comment https://forums.phpfreaks.com/topic/86959-solved-noob-finishing-touches-on-drop-down-form-ty/#findComment-444623 Share on other sites More sharing options...
Thundarfoot Posted January 22, 2008 Author Share Posted January 22, 2008 I swear this is kicking my tail lol I am trying if statements, but nothing I can figure out is working (though I have learned some about elseif statemets, just not enough I guess... Quote Link to comment https://forums.phpfreaks.com/topic/86959-solved-noob-finishing-touches-on-drop-down-form-ty/#findComment-445908 Share on other sites More sharing options...
mmarif4u Posted January 22, 2008 Share Posted January 22, 2008 Can u show us the modified code. Quote Link to comment https://forums.phpfreaks.com/topic/86959-solved-noob-finishing-touches-on-drop-down-form-ty/#findComment-445911 Share on other sites More sharing options...
Thundarfoot Posted January 22, 2008 Author Share Posted January 22, 2008 well I have tried a lot of diffrent things, trying to put if statement with the query and such...now I am trying to put the if statement with the table output it thought that it will not display table unless if statement is true... this is the current code piece I am playing with. if ($name == “^.+”) { <table border="1" cellpadding="5" cellspacing="5"> <tr> <td>Name</td> <td>Class</td> <td>Drops</td> <td>Details</td> </tr> <?php do { ?> <tr> <td><?php echo $row_Cards['Name']; ?></td> <td><?php echo $row_Cards['Class']; ?></td> <td><?php echo $row_Cards['Drops']; ?></td> <td><?php echo $row_Cards['Details']; ?></td> </tr> <?php } while ($row_Cards = mysql_fetch_assoc($Cards)); ?> </table> } else { echo “Please Select<br>”; } Quote Link to comment https://forums.phpfreaks.com/topic/86959-solved-noob-finishing-touches-on-drop-down-form-ty/#findComment-446449 Share on other sites More sharing options...
Thundarfoot Posted January 23, 2008 Author Share Posted January 23, 2008 when one path wont work, seek another. I found a work around...but thank you for all your help Quote Link to comment https://forums.phpfreaks.com/topic/86959-solved-noob-finishing-touches-on-drop-down-form-ty/#findComment-446615 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.