fou循环 php 剩余次数_php foreach 循环次数如何设置?

wordpress主题首页限制循环次数我的部分代码<?phpif ($total_portfolio_cat){$count=0;$args=array('...

wordpress 主题 首页限制循环次数我的部分代码

<?php if($total_portfolio_cat){$count = 0;$args = array( 'cat' => $total_portfolio_cat, 'posts_per_page' => -1 );$query = new WP_Query($args);if($query->have_posts()):while($query->have_posts()) : $query->the_post();$categories = get_the_category(); $category_slug = ""; $cat_slug = array(); foreach ($categories as $category) { $cat_slug[] = 'total-portfolio-'.$category->term_id; } $category_slug = implode(" ", $cat_slug); if(has_post_thumbnail()){ $image_url = get_template_directory_uri().'/images/portfolio-small-blank.png'; $total_image = wp_get_attachment_image_src(get_post_thumbnail_id(),'total-portfolio-thumb');$total_image_large = wp_get_attachment_image_src(get_post_thumbnail_id(),'large'); }else{ $image_url = get_template_directory_uri().'/images/portfolio-small.png'; $total_image = ""; }?>

展开

import java.sql.*; import java.util.Scanner; public class keshe { public static String stu_name; public static String Enrollment_time; public static String Faculties; public static String majors; public static String stu_class; public static String stu_num;//学号 public static String Course; public static String fir_sem; public static String sec_sem; public static String thr_sem; public static String fou_sem; public static String fiv_sem; public static String six_sem; public static String sev_sem; public static String eig_sem; static Connection conn; static Statement stmt = null; public static void main(String[] args) throws SQLException { String url = "jdbc:mysql://localhost:3306/student"; String username = "root"; String password = "qwj1514399005"; try { Class.forName("com.mysql.cj.jdbc.Driver"); } catch (Exception e) { e.printStackTrace(); } try { conn = DriverManager.getConnection(url, username, password); stmt = conn.createStatement(); } catch (Exception e) { e.printStackTrace(); } } //插入课程名字和成绩 public static void Insert_course() throws SQLException { try { PreparedStatement prestmt = conn.prepareStatement("INSERT INTO Course_grades(course,fir_sem,sec_sem,thr_sem,fou_sem,fiv_sem,six_sem,sev_sem,eig_sem,stu_name,stu_num)VALUES (?, ?, ?, ?, ?,?, ?, ?, ?, ?,?)"); System.out.println("分别输入插入的课程名,第一学期成绩,第二学期成绩,第三学期成绩,第四学期成绩,第五学期成绩,第六学期成绩,第七学期成绩,第八学期成绩,学生姓名,学号"); Scanner scan = new Scanner(System.in); Course = scan.nextLine(); fir_sem = scan.nextLine(); sec_sem = scan.nextLine(); thr_sem = scan.nextLine(); fou_sem = scan.nextLine(); fiv_sem = scan.nextLine(); six_sem = scan.nextLine(); sev_sem = scan.nextLine(); eig_sem = scan.nextLine(); stu_name = scan.nextLine(); stu_num = scan.nextLine(); prestmt.setString(1,Course ); prestmt.setString(2,fir_sem ); prestmt.setString(3,sec_sem ); prestmt.setString(4,thr_sem ); prestmt.setString(5,fou_sem ); prestmt.setString(6,fiv_sem ); prestmt.setString(7,six_sem ); prestmt.setString(8,sev_sem ); prestmt.setString(9,eig_sem ); prestmt.setString(10,stu_name ); prestmt.setString(11,stu_num ); prestmt.executeUpdate(); prestmt.close(); System.out.println("插入学生课程成功"); }catch (Exception e){ e.printStackTrace(); System.out.println("插入出错"); } } 添加可以计算出所有人的总分和平均分,课程的平均分 直接给出代码
06-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值