tmfl Posted May 19, 2009 Share Posted May 19, 2009 Hi, This is my first post here and I'm trying to do something which I thought would be simple enough but is starting to really annoy me now! I'm using a form which a user predicts winning margins in a football fixtures list while ($row = $res->fetch_array(MYSQLI_NUM)) { echo '<input type="hidden" name="fixture['.$row[0].']" value ="">'; echo '<tr><td>'.$row[2].'</td>'; echo '<td class="fixtures"><select name = "team1" id="team1"/><option value=""></option>'; for ($i = 1; $i < 31; $i++) echo '<option value="'.$i.'">'.$i.'</option>'; echo '</td>'; echo '<td class="fixtures"><input type="checkbox" name="f'.$row[0].'draw" id="f'.$row[0].'draw" value="1"/></td>'; echo '<td class="fixtures"><select name = "team2" id="team2"/><option value=""></option>'; for ($i = 1; $i < 31; $i++) echo '<option value="'.$i.'">'.$i.'</option>'; echo '</td>'; echo '<td>'.$row[4].'</td>'; echo '</tr>'; } The code above retrieves a round of fixtures from a database and outputs team names, dropdown lists of winning margins and a checkbox for a draw e.g. Team 1 beats Teams 2 by 5 goals in fixture 1 I want to be able to insert each fixture prediction into my predictions table when the user submits the form At the moment my query string looks like prelatfixh.php?fixture[1]=&team1=5&team2=&fixture[2]=&team1=&team2=&fixture[3].......... Is there a method where i can access the value of fixture[1] = team1=5 where it will only pick team that has a value set as only one team will have a value per fixture (or a draw which would be fixture1draw=1) and for all fixtures Something like foreach fixture get value. I've tried various ways but get Array as an answer or incorrect index if i do $_GET['fixture'] or $_GET['fixture[]'] Is this even the smartest way to approach this ? Many thanks in advance tmfl Link to comment https://forums.phpfreaks.com/topic/158735-how-do-i-access-array-values-within-the-query-string/ Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 Maybe make use of your own predetermined special character to join pieces of information: fixture1=team1_5 Then, later on... $fixture1_split = explode("_", $_GET['fixture1']); //now, $fixture1_split[0] stores "team1" and $fixture1_split[1] stores "5" Hope this helps (though I'm not sure it will). Link to comment https://forums.phpfreaks.com/topic/158735-how-do-i-access-array-values-within-the-query-string/#findComment-837169 Share on other sites More sharing options...
tmfl Posted May 19, 2009 Author Share Posted May 19, 2009 wow...thats a quick response.....thanks....i'll give it a go Link to comment https://forums.phpfreaks.com/topic/158735-how-do-i-access-array-values-within-the-query-string/#findComment-837174 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.