I have a php page that gets values from my database called print.php which I use to display and print the values from my database.

我有一个php页面,从我的数据库中获取名为print.php的值,我用它来显示和打印数据库中的值。

print.php?id=100 loads the page with values from the database that has the id 100. each record on my database has a field to store the date the record was created. As for now I visit print.php?id=100, print.php?id=101, print.php?id=102, print.php?id=103 and so on to print the same page but with various values.

print.php?id = 100使用ID为100的数据库中的值加载页面。我的数据库中的每个记录都有一个字段来存储创建记录的日期。至于现在我访问print.php?id = 100,print.php?id = 101,print.php?id = 102,print.php?id = 103等等,以打印相同的页面但具有各种值。

Is there a way for me to create a button which does this automatically?

有没有办法让我创建一个自动执行此操作的按钮?

This button should grab all records that have the current date and print all those pages.

此按钮应获取具有当前日期的所有记录并打印所有这些页面。

Sorry for being unclear.

很抱歉不清楚。

My print.php page echos values from my database like this: Id: <?php echo $info['id']; ?> Name: <?php echo $info['name']; ?> Date: <?php echo $info['date']; ?> Gender: <?php echo $info['gender']; ?>

我的print.php页面回显了我的数据库中的值,如下所示:Id: 名称: 日期:

So for example visiting print.php?id=100 loads these values: Id: 100 Name: John Date: 2013-04-09 Gender: Male

所以例如访问print.php?id = 100加载这些值:Id:100姓名:John日期:2013-04-09性别:男

Cisiting print.php?id=101 loads these values: Id: 101 Name: Sarah Date: 2013-04-09 Gender: Female

Cisiting print.php?id = 101加载这些值:Id:101姓名:Sarah日期:2013-04-09性别:女

and so on.

等等。

When visiting each page I hit CTRL+P to print that information.

访问每个页面时,我按CTRL + P打印该信息。

Instead of doing this manually (visiting each page and sending it to printer) I would like to have a script which grabs all the records of current date and sends it to my printer.

而不是手动执行此操作(访问每个页面并将其发送到打印机),我希望有一个脚本可以抓取当前日期的所有记录并将其发送到我的打印机。

2 个解决方案

#1


0

I'm not sure what you want to archieve, but I think you want a form like this:

我不确定你想要什么,但我认为你想要一个这样的形式:

<form method="get" action="">
    <input type="text" name="id" value="100"/>
    <input type="submit"/>
</form>

this would redirect the user to print.php?id=100 or with the value given in the textbox

这会将用户重定向到print.php?id = 100或文本框中给出的值

EDIT:

What I read from the comments on the question is this what you want to archieve:

我从这个问题的评论中读到的是你想要达成的目标:

<form method="get" action="">
    <input type="text" name="date" value="<?=date('yyyy-mm-dd');?>"/>
    <input type="submit"/>
</form>

this would show a form with a textfield with the date of today printed in.

这将显示一个带有文本字段的表单,其中包含今天的日期。

then you should make a query and fetch it like this:

那么你应该进行查询并像这样获取它:

$date = check_date($_GET['date']);
$query = 'SELECT * FROM values WHERE date="'.$date.'"';
if ($result = $mysqli->query($query)) {
    while ($row = $result->fetch_assoc()) {
        // print row
    }
}

the function check_date() is up to you to create, this checks if the text is a valid date to make sure nobody can hack your database

函数check_date()取决于你创建,这将检查文本是否是一个有效的日期,以确保没有人可以破解你的数据库

更多相关文章

  1. PHP日期添加1年到当前日期。
  2. 如何递归将特色图像应用于Wordpress中的子页面?
  3. 将STR_TO_DATE格式化为日期
  4. 更新日期字段时为空 - MySQL PHP
  5. phpnow1.5.6如何设置404错误页面?
  6. 使用date_default_timezone_set和日期的可能的PHP bug ?
  7. 关于PHP 读取EXCEL时间(不是日期)的问题
  8. 海图没有显示任何东西,只是空白的html页面
  9. Laravel 5验证日期为php Y格式。g 2015 ?

随机推荐

  1. PHP使用redis作为缓存(高效技术)
  2. php性能优化的方法介绍
  3. php实现顺序线性表
  4. Kubernetes 如果是个水族馆
  5. 自学系列 | 就谈自我管理!
  6. 智慧城市信息安全探讨
  7. 1-22
  8. 动画:面试必刷之二叉树的子结构
  9. 详解 centos7设置nfs文件共享 实操记
  10. 2020 总结 | VoltDB的亮点,你了解多少?