制作重复语法的数组

时间:2016-03-29 05:30:09

标签: php

我可以制作以下重复语法的数组和循环:

$row1=mysql_fetch_array(mysql_query("SELECT `name_of_book` from `mytable` where  = `date_borrow`= curdate() ));
$row2=mysql_fetch_array(mysql_query("SELECT `name_of_book` from `mytable` where  = `date_borrow`= curdate()+1 ));
$row3=mysql_fetch_array(mysql_query("SELECT `name_of_book` from `mytable` where  = `date_borrow`= curdate()+2 ));
$row4=mysql_fetch_array(mysql_query("SELECT `name_of_book` from `mytable` where  = `date_borrow`= curdate()+3 ));
.
.
.
.
$row50=mysql_fetch_array(mysql_query("SELECT `name_of_book` from `mytable` where  = `date_borrow`= curdate()+49 ));

以及如何回显$ row23的name_of_book

由于

1 个答案:

答案 0 :(得分:0)

这样的事情可以解决问题。

$rows = mysql_query("SELECT name_of_book, date_borrow from mytable where date_borrow < DATE_ADD(CURDATE(), INTERVAL 50 DAY) ");

$i = 0;
while ($row = mysql_fetch_assoc($rows)) {
    if($i>22 || $i < 41){
      echo $row["name_of_book"];
      echo $row["date_borrow"];  
     }
    $i = $i+1;
}