0
<?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

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

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
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Heri
  • 61
  • 6
  • 3
    Every time you use [the `mysql_`](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) database extension in new code **[a Kitten is strangled somewhere in the world](http://2.bp.blogspot.com/-zCT6jizimfI/UjJ5UTb_BeI/AAAAAAAACgg/AS6XCd6aNdg/s1600/luna_getting_strangled.jpg)** it is deprecated and has been for years and is gone for ever in PHP7. If you are just learning PHP, spend your energies learning the `PDO` or `mysqli` database extensions. [Start here](http://php.net/manual/en/book.pdo.php) – RiggsFolly Jan 02 '17 at 15:15
  • 2
    Your script is at risk of [SQL Injection Attack](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) Have a look at what happened to [Little Bobby Tables](http://bobby-tables.com/) Even [if you are escaping inputs, its not safe!](http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string) Use [prepared parameterized statements](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) – RiggsFolly Jan 02 '17 at 15:16
  • I really think PhP community should do something about [the `mysql_*`](http://php.net/manual/en/mysql.examples-basic.php) pages and add a red alert div to prevent people from using this library. – Anwar Jan 02 '17 at 15:23
  • 1
    can't you use an [autoincrement](http://dev.mysql.com/doc/refman/5.7/en/example-auto-increment.html)? – Jeff Jan 02 '17 at 15:30
  • no, i'm not, when the power of electricity down i'll be the same and had limit for queue – Heri Jan 02 '17 at 15:36
  • Won't the server be offline when there is no electricity so nothing will happen? I don't see why auto-incrementing the column wouldnt work. – chris85 Jan 02 '17 at 15:46
  • You haven't explained your failure. – Aaron Jan 02 '17 at 17:07

1 Answers1

3

mysql_fetch_array() returns array not string. Here is reference http://php.net/manual/en/function.mysql-fetch-array.php

In your case: $three = 1 + (int)$checknumber[0]['number']; Or you can use while or foreach loop.

You could set auto incremental column in your database. Also you should use PDO or MYSQLi.

Mehedee
  • 336
  • 1
  • 9