[英]Select and insert using php mysql?
<?php
include "conection.php";
$checknumber=mysql_fetch_array(mysql_query("SELECT MAX( number ) FROM tqueue WHERE get_ticket >= CURDATE( ) GROUP BY services"));
$one=$_GET['services'];
$two=$_GET['services_abjact'];
$three=1+(int)$checknumber;
$query="INSERT INTO tqueue (services, services_abjact, number) values ('$one', '$two','$three')";
$exe=mysql_query($query);
echo"<a href='index.php'>Input again</a></br>";
?>
i want to input link like this http://localhost/pehape/input.php?services=1&services_abjact=A&submit=save 我想输入这样的链接http://localhost/pehape/input.php?services = 1&services_abjact = A&submit = save
When I input that link I'll get sequential number of queue with using +1 in $three or number column but I'm still failing in result please help me 当我输入该链接时,我将在$ three或number列中使用+1来获得连续的队列编号,但结果仍然失败,请帮助我
I want result in number column something like this table 我想在数字列中生成类似于此表的结果
-----------------------------------------------------------
services | services abjact | number | get_ticket
-----------------------------------------------------------
1 A 12 21:04:24
1 A 11 20:00:00
1 A 10 19:02:40
1 A 9 18:36:01
1 A 8 18:01:00
1 A 7 17:45:30
1 A 6 16:50:20
1 A 5 16:34:56
1 A 4 16:03:04
1 A 3 15:00:00
1 A 2 11:56:00
1 A 1 09:12:34
mysql_fetch_array() returns array not string. mysql_fetch_array()返回数组而不是字符串。 Here is reference http://php.net/manual/en/function.mysql-fetch-array.php 这是参考http://php.net/manual/en/function.mysql-fetch-array.php
In your case: $three = 1 + (int)$checknumber[0]['number'];
在您的情况下: $three = 1 + (int)$checknumber[0]['number'];
Or you can use while or foreach loop. 或者您可以使用while或foreach循环。
You could set auto incremental column in your database. 您可以在数据库中设置自动增量列。 Also you should use PDO or MYSQLi. 另外,您应该使用PDO或MYSQLi。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.