dpjhq00684 2014-11-30 06:14
浏览 51

如何从多个选项中正确选择数据库插入数据?

I know the title is a bit confusing but I wasn't exactly sure how to describe my issue and none of my numerous searches online and here returned any positive results..

What I'm trying to do is allow a user to 'choose' one set from multiple sets of numbers for inclusion into the database. The image below should with the visualization of my goal.

multiple sets to choose from

As you can see from the above image, there's a "button" to the right that states "keep this set". My goal is to allow the user to click the button and the corresponding set of values is then entered into the database as a string (the values aren't being used in any calculations afterwards just being displayed on screen.)

The following code below works for auto-insertion if there's only one set generated but nothing I've attempted so far works when it comes to allowing the user to choose one set they'd like entered.

<?php

additional code here...

echo '<table><tr><td>';

for($i=1; $i<=$Sets; $i++){
    $Stat_Results = GenStats($SpecId, $min, $Quantity, $Type);

    echo "Stat values for ".$SetGenerated[$i];

   foreach($Stat_Results as $key => $DisplayStats){
          echo $DisplayStats.', ';
   }

   if($Sets == 1){
     $SetResults = implode(',',$Stat_Results);
     DB_Insert($UserId, $SetResults, $TimeStamp);   
   }else if($Sets >= 2){
     echo "</td><td> => <input type='button' name='submit' value='keep this set'></td>
     <tr><td>";
   }
}   
echo '</td></tr></table>';
?>

html below here....

Variables: $SpecId, $min, $Quantity, $Type, $Sets, $UserId, and $TimeStamp are all set in a section not shown in this snippet.

I've tried Javascript but too be honest, I'm not all that familiar with it (though I am trying to become more fluid in it) and I've went so far as to try to create the multiple sets as a dropdown box thinking the user could simply select it from there and it be treated as a dynamic form and php would do the rest. But that didn't work either. The form button for submission is the remnant of the list I tried to generate. The form is no longer there. I left it in there to generate the image you see above and has since been removed from the actual code.

I admit, I'm stuck and need some guidance because I can't seem to make this work no matter what I do.

Thanks to all who read and attempt to help!

P.S: I apologize in advance for the title and for the sloppy code. I tried to format it but was having difficulty getting it to look right using the WYSIWYG editor on this site.

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 keil的map文件中Image component sizes各项意思
    • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 Centos / PETGEM
    • ¥15 划分vlan后不通了
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)