rascle Posted March 13, 2010 Share Posted March 13, 2010 Hi I am using some code that i dont quite understand and i need some help here is the code so far: if(isset($_GET['box'])){ $box = $_GET['box']; echo '<form name="edit" method="get">'; while(list($key,$val)= @each ($box)){ $rhys = mysql_query("SELECT * FROM games WHERE gamenumb = '$val'"); while($oldgame = mysql_fetch_array($rhys)){ echo' <input type="hidden" value="'.$oldgame['gamenumb'].'" name="editcheck[]"> Game Name: <div id="addgameinput"><input type="text" size="100" maxlength="150" name="gamename" class="input1" value="'.$oldgame['text'].'"></div><br/> <br/> <hr/><br/>'; } } echo'<center><input type="submit" class="submit"></center></form>'; }else if(isset($_GET['editcheck'])){ $rhys = $_GET['editcheck']; while(list($key,$val)= @each ($rhys)){ $rhys2 = $_GET['gamename']; echo "$val <br/> $rhys2 <br/> "; } }else{ echo"<table border='1'> <tr> <td><form name='multiselect' method='get'></td> </tr> <tr> <th>Check</th> </tr> "; $getgames = mysql_query("SELECT * FROM games ORDER BY `gamenumb`"); while($game = mysql_fetch_array($getgames)){ $id = $game['gamenumb']; echo"<tr>"; echo '<td><input type="checkbox" name="box[]" value="'.$game['gamenumb'].'" class="check"></td>'; echo "<td>"; echo "</tr>"; } echo "<tr><td><input type='submit' value='Edit'></form></td></tr>"; echo "</table>"; } At the moment When i check the checkbox and click submit it will take me to the edit page and then i can make an edit click submit and go to a page which will use mysql to submit the data to a db, the only problem is, is that at the moment i can only seem to list the game number and not the edits that have been made to the game, to do this i would need to change something on the while loop where the list() is but i am not sure what to change it to. Any Ideas? Thanks Rhys Link to comment https://forums.phpfreaks.com/topic/195134-php-array-list/ Share on other sites More sharing options...
teamatomic Posted March 13, 2010 Share Posted March 13, 2010 SELECT wont do if you want to change values in a DB. You need to use either INSERT or UPDATE. If you already have tables and fields that are populated then use UPDATE. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/195134-php-array-list/#findComment-1025722 Share on other sites More sharing options...
rascle Posted March 14, 2010 Author Share Posted March 14, 2010 Where does it say SELECT ??? Anyway that isnt the problem the problem is selecting the multi array fields Link to comment https://forums.phpfreaks.com/topic/195134-php-array-list/#findComment-1025857 Share on other sites More sharing options...
rascle Posted March 14, 2010 Author Share Posted March 14, 2010 THe only problem is is that on the code with }else if(isset($_GET['editcheck'])){ $rhys = $_GET['editcheck']; while(list($key,$val)= @each ($rhys)){ $rhys2 = $_GET['gamename']; echo "$val <br/> $rhys2 <br/> "; } I cant get it to display all of the entries that have been editted, since i would need some kind of while loop that can display the arrays in - this i do not know how to do. Thanks Link to comment https://forums.phpfreaks.com/topic/195134-php-array-list/#findComment-1025910 Share on other sites More sharing options...
wildteen88 Posted March 14, 2010 Share Posted March 14, 2010 When processing your checkboxes your code can be simplified and be much more efficient. So instead of this while(list($key,$val)= @each ($box)){ $rhys = mysql_query("SELECT * FROM games WHERE gamenumb = '$val'"); while($oldgame = mysql_fetch_array($rhys)){ echo' <input type="hidden" value="'.$oldgame['gamenumb'].'" name="editcheck[]"> Game Name: <div id="addgameinput"><input type="text" size="100" maxlength="150" name="gamename" class="input1" value="'.$oldgame['text'].'"></div><br/> <br/> <hr/><br/>'; } } You can do $ids = implode(',', $box); $rhys = mysql_query("SELECT * FROM games WHERE gamenumb IN ($ids)"); while($oldgame = mysql_fetch_array($rhys)) { echo'<input type="hidden" value="'.$oldgame['gamenumb'].'" name="editcheck[]"> Game Name: <div id="addgameinput"><input type="text" size="100" maxlength="150" name="gamename" class="input1" value="'.$oldgame['text'].'"></div><br/> <br/> <hr/><br/>'; } Link to comment https://forums.phpfreaks.com/topic/195134-php-array-list/#findComment-1025931 Share on other sites More sharing options...
rascle Posted March 14, 2010 Author Share Posted March 14, 2010 Thanks for that do you have any idea how i could use that on the editcheck part? Link to comment https://forums.phpfreaks.com/topic/195134-php-array-list/#findComment-1025960 Share on other sites More sharing options...
rascle Posted March 14, 2010 Author Share Posted March 14, 2010 any ideas? Link to comment https://forums.phpfreaks.com/topic/195134-php-array-list/#findComment-1025997 Share on other sites More sharing options...
rascle Posted March 15, 2010 Author Share Posted March 15, 2010 Should i not use arrays on isset($_GET['editcheck'])) ? Link to comment https://forums.phpfreaks.com/topic/195134-php-array-list/#findComment-1026595 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.