douxueke5653 2017-03-08 16:39
浏览 28

复选框验证和MySQL数据插入

I am trying to customize a script for checkbox.

I have progressed to the following and successfully echoed to screen:

$q="Select id, subject From subjects";
     $r=mysqli_query ($d, $q);
     If (mysqli_num_rows($r)>0) {
        while ($row =mysqli_ferch_array($r, MYSQLI_NUM)) {
                Echo "<input type=\"checkbox\" name=\"$row[1]\" value=\"$row[0]\">$row[1]";
     }}

Now,

I am trying to insert the resultant data into a different table (for example student) as follows:

$q = 'INSERT INTO student (id) VALUES (?)';
$stmt = mysqli_prepare($d,$q);
mysqli_stmt_bind+param($stmt, 'i', $_POST[?);
mysqli_stmt_execute($stmt);

However, this is not working.

Where I am lost is trying to understand the variables:

$row, $row[0] $row[1] and sql 'subject' sql 'id'

What value will $_POST receive and how do I insert into a database using the above procedural type code that was used for a select statement.

If possible, would you provide an example?

Also, any explanation of the variables listed above and their uses would be helpful!

I have looked through the site, but still am a little confused.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?