RE: [PHP-DB] Re: checkbox into mysql using php <input type="checkbox" name="list
| From: | Bastien Koert | Date: | Thu, 17 Feb 2005 14:13:27 +0000 |
| Subject: | RE: [PHP-DB] Re: checkbox into mysql using php <input type="checkbox" name="list | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-38605@lists.php.net to get a copy of this message | ||
if its all going into one col, then implode the array into a string
$data = implode(",",$_POST['games']);
Then insert the data. Still doesn't relieve you of the need to validate the user data.
Bastien
From: "moses Woldeselassie" <mmoses@hotmail.com> To: php-db@lists.php.net, bastien_k@hotmail.com Subject: RE: [PHP-DB] Re: checkbox into mysql using php <input type="checkbox" name="list Date: Thu, 17 Feb 2005 10:21:31 +0000 thank Bastien I did try that, but the input is going into one column or it is take the last array value and put it each chart in the table. <input type="checkbox" name="games[]" value="football" /> in that case, these are the value i got in mysql: f, o, o, tforeach($_POST['games'] AS $game => $value)$valuecount = count($_POST['games']); for($i =0; $i < $valuecount; $i++) $sql = mysql_query("insert into interest values('$value[0]','$value[1]','$value[2]','$value[3]')"); i'm looking forward to hearing from you. kind regards; m >From: "Bastien Koert" <bastien_k@hotmail.com> >To: mmoses@hotmail.com, php-db@lists.php.net >Subject: RE: [PHP-DB] Re: checkbox into mysql using php <input type="checkbox" name="list >Date: Wed, 16 Feb 2005 21:38:10 -0500 > >$value is not an array...wont run > >try > >$valuecount = count($_POST['games']); > >bastien > >>From: "moses Woldeselassie" <mmoses@hotmail.com> >>To: php-db@lists.php.net >>Subject: RE: [PHP-DB] Re: checkbox into mysql using php <input >>type="checkbox" name="list >>Date: Wed, 16 Feb 2005 22:09:09 +0000 >> >>Thank you, >> >>i don't have any problem using that syntax: >>if (isset($_POST['submit'])) {>> echo "You chose the following games:<br />"; >> foreach($_POST['games'] AS $game => $value)>> $sql = mysql_query("insert into interest(username) >>values('$value')"); >> >>but the problem is with the following: >> >> >>$valuecount = count($value) >>for($i =0; $i < $valuecount; $i++) { >>$sql = mysql_query("insert into interest values('$value', >>'$value[$i]')"); >> >>I don't get any input into mysql. >> >>kind regards >>m >> >> >>&gt;From: pete M &lt;pmorgan@ukds.net&gt; >>&gt;To: php-db@lists.php.net >>&gt;Subject: [PHP-DB] Re: checkbox into mysql using php &lt;input >>type=&quot;checkbox&quot; >>name=&quot;list[]&quot;value=&quot;x&quot;&gt; >>&gt;Date: Wed, 16 Feb 2005 18:22:14 +0000 >>&gt; >>&gt;foreach($_POST['name'] as $k =&gt; $v){ >>&gt; >>&gt;} >>&gt; >>&gt;moses Woldeselassie wrote: >>&gt;&gt;hi all >>&gt;&gt; >>&gt;&gt; >>&gt;&gt;I need a simple php script to use for html >>&gt;&gt; >>&gt;&gt; >>&gt;&gt; >>&gt;&gt;&lt;form action=&quot;checkbox.php&quot; >>method=&quot;post&quot;&gt; >>&gt;&gt; Select from the list &lt;br /&gt; (check all that >>apply):&lt;br /&gt; >>&gt;&gt; &lt;input type=&quot;checkbox&quot; >>name=&quot;list[]&quot; value=&quot;x&quot;&gt; >>&gt;&gt; &lt;input type=&quot;checkbox&quot; >>name=&quot;list[]&quot; value=&quot;y&quot;&gt; >>&gt;&gt;&lt;input type=&quot;submit&quot; name=&quot;submit&quot; >>value=&quot;Go!&quot; /&gt; >>&gt;&gt;&lt;/form&gt; >>&gt;&gt; >>&gt;&gt;kind regards >>&gt;&gt;meberat >>&gt; >>&gt;-- >>&gt;PHP Database Mailing List (http://www.php.net/) >>&gt;To unsubscribe, visit: http://www.php.net/unsub.php >>&gt; >> >>-- >>PHP Database Mailing List (http://www.php.net/) >>To unsubscribe, visit: http://www.php.net/unsub.php >> > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php