Results 1 to 9 of 9
Thread: Checkbox mySQL / PHP
Hybrid View
-
14th March 2010 14:40 #1
Checkbox mySQL / PHP
,
.
( ID, Name) checkbox VALUE ID . , . , ID ID .
- , . , , . .
.
-
14th March 2010 16:56 #2
name name="categories[]", value ID-, .. :
<input type="checkbox" name="categories[]" value="1" />
<input type="checkbox" name="categories[]" value="2" />
<input type="checkbox" name="categories[]" value="3" />
- $_POST['categories'] ( $_GET['categories']) foreach value-, - . , - .
P.S. - html php , - .''? * *
- !
...
-
14th March 2010 17:30 #3
!!!
if(isset($_POST['checkbox']))
{
foreach ($_POST['checkbox'] as $value){
$checkbox= $_POST['checkbox'];
$n = count($checkbox);
$i = 0;
}
while ($i < $n)
{
$id_query = "INSERT into tbl(obj_id, category_id) VALUES ('$id_obj', '$checkbox[$i]]')";
mysql_query($id_query) or die(mysql_error());
$i++;
}
}
-
14th March 2010 18:42 #4
?

foreach .
while for .
.
---------- Post added at 18:42 ---------- Previous post was at 18:34 ----------
. $id_obj , AUTO_INCREMENT, ID.
category_id integer - $value .
PHP Code:<?php
if (isset($_POST['checkbox'])) {
foreach ($_POST['checkbox'] as $value){
//$value = mysql_real_escape_string($value); // , integer
$value = intval($value);
$id_query = "INSERT into tbl(obj_id, category_id) VALUES ('$id_obj', '$value')";
mysql_query($id_query) or die(mysql_error());
}
}
?>''? * *
- !
...
-
14th March 2010 18:48 #5
, , foreach -.
foreach ($_POST['checkbox'] as $value) {
// tuk wkarvash prosto w DB VALUES ($id_obj, $value)
}
$value integer, .
vbTheKing:
" $id_obj , AUTO_INCREMENT, ID."
- --, . auto_increment , ID - - .
-
14th March 2010 22:16 #6
-
14th March 2010 22:44 #7
, ... foreach . :
$checkbox= $_POST['checkbox'];
$n = count($checkbox);
$i = 0;
, -, .
while- . - for , :
for ($i=0; $i < $n; $i++) {
}
, . , , , () .''? * *
- !
...
-
14th March 2010 23:24 #8
-
15th March 2010 01:38 #9
DonDale, , , .
PHP , , , , , , .
, . .
. , , 5 , 3 .. 5
.
foreach , ?
foreach for vbTheKing, - , , 5-10-20-50 . , , , security through obscurity
.




Reply With Quote


Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in