-1
<?php
$con=  mysql_connect("localhost","root","");
      $d=mysql_select_db("laabhaa_crm",$con);

    $result=mysql_query("SELECT MAX(LT_8690) 
FROM lead") or die(mysql_error());

 if($row=mysql_fetch_assoc($result))
 $a=$row['MAX(LT_8690)']+1;

  ?> 
  <input type="text" readonly="readonly" value="LT" style="width:16px;"/>/
                    <input name="LT_8690" type="text" value="<?php echo $a;?>" readonly="readonly" id="" style="width:60px;">

                </td>
            </tr>
Mark Baker
  • 209,507
  • 32
  • 346
  • 385
  • What is this... Post your query as well – Sunil Pachlangia May 07 '15 at 12:59
  • The query is posted. Read it again Sunil. – Muhammad Abdul-Rahim May 07 '15 at 13:01
  • 1
    Please, [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). Learn about [prepared statements](http://en.wikipedia.org/wiki/Prepared_statement) instead, and consider using PDO, [it's not as hard as you think](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard May 07 '15 at 13:02
  • i am not getting to increment $a value after 10 .when i run my program then its doesnt works – Rahul Kashyap May 07 '15 at 13:03

1 Answers1

1

Your query is this:

SELECT MAX(LT_8690) 
FROM lead

The way you're trying to access that field is like this:

$row['MAX(LT_8690)']

This is incorrect. The column's name is not MAX(LT_8690). The column doesn't have a name. Let's give it one, as such:

SELECT MAX(LT_8690) AS 'maxLt8690'
FROM lead

$row['maxLt8690']

I like this option because I get to be specific with names. This makes my code more readable, which helps me when I have to go back and update it.

Muhammad Abdul-Rahim
  • 1,980
  • 19
  • 31