我需要做的是将用户选中的任何内容插入到我们在数据库中创建的表中。我能够将数据存储到数组中,但后来我无法将它存储到数据库中。通过PHP发送复选框到MySQL
<form>
<input type="checkbox" name="partType[]" value="GenericBreakPads" /> Generic Break Pads
<input type="checkbox" name="partType[]" value="Air_Conditioning_Compressor" /> Air Conditioning Compressor
<input type="checkbox" name="partType[]" value="Generic_Battery" /> Generic Battery <br />
<input type="checkbox" name="partType[]" value="Carburetor" /> Carburetor
<input type="checkbox" name="partType[]" value="Engine_Balance_Shaft" /> Engine Balance Shaft
<input type="checkbox" name="partType[]" value="Engine_Cylinder" /> Engine Cylinder
</form>
我已经尝试过序列化,但由于它存储到表中的方式并不是很有帮助。
$theParts=serialize($_POST['partType']); //takes the data from a post operation...
$query=INSERT INTO parts VALUES('$partType');
如果有人可以帮助我,我会非常感激!
发布您的表格结构! – Bil 2011-04-21 00:37:52
你想要如何存储数据?在单列中?在多个栏目中,作为m2m关系? – prodigitalson 2011-04-21 00:39:17
你真的想输入:'$ theParts ='**'mysql_real_escape_string' **'(serialize($ _ POST ['partType'])); //从后期操作中获取数据... $ query = INSERT INTO部分VALUES('$ partType'); “对,对吗? – Johan 2011-04-21 00:40:07