我想在PHP中插入多个数组值 [英] I want to inserting multiple array values in PHP
本文介绍了我想在PHP中插入多个数组值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在db中插入多个数组值。
我尝试过:
$ sqlquery = $ connect-> query( SELECT * FROM student,finalresults WHERE finalresults.stid = student.userid);
while ( $ rows = $ sqlquery-> fetch_assoc()) {
$ total = $ rows [ 标记跨度>];
$ average = $ total / 10;
// 此处将两个值作为数组值
$ values [] = ('{$ rows ['courseid']}','{$ rows ['marks' ]});
// 此处将两个值作为数组值
$ wastan [] = 总计:$ total,平均值:$ average;
}
for($ x = 1 ; $ x< = count($ values); $ x ++){
// 这里我强迫10个主题由唯一学生ID一起显示
if( !(($ i ++)%10)){
print $ values [$ x];
print < hr>< /跨度>;
} esle { print $ values [$ x]; }
解决方案
sqlquery =
connect-> ; query( SELECT * FROM student,finalresults WHERE finalresults.stid = student.userid);
while (
rows =
I want to inserting multiple array values into db.
What I have tried:
$sqlquery = $connect->query("SELECT * FROM student,finalresults WHERE finalresults.stid = student.userid");
while ( $rows = $sqlquery->fetch_assoc() ) {
$total = $rows["marks"];
$average = $total/10;
//takes two values here as array values
$values[] = "( '{$rows['courseid']}', '{$rows['marks']}') ";
//takes two values here as array values
$wastan[] = "Total:$total,Average: $average";
}
for($x = 1; $x<=count($values); $x++){
//Here I force 10 subject to display together by unique student ID
if(!(($i++) % 10)){
print $values[$x];
print "<hr>";
} esle{ print $values[$x]; } }
解决方案
sqlquery =
connect->query("SELECT * FROM student,finalresults WHERE finalresults.stid = student.userid"); while (
rows =
这篇关于我想在PHP中插入多个数组值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文