Auto increment a SELECT result in a value attribute

I am trying to use a SELECT to get the last invoice number generated then auto increment it to put in the value attribute of a form.

<?php   mysql_select_db("customers", $dbconn);
      $invNum = mysql_query("SELECT MAX(invId) FROM invoices", $dbconn);?>

   <td><input type="text" name="invNum" id="invNum" 
          size="12" value="<?php echo ++$invNum; ?>"</td>

in my play data base the last invoice is 103…

what echos in the value is Resource id #3 instead of 104.

can this be done if so can someone point me in the right direction.

Thank you

Besides using obsolete msyql when you should be using mysqli or PDO (my recommendation), you could just auto increment the invoice number in MySQL. :frowning:


I know the mysql is old. I am more familuar with it so am using it while building. I want the invoice # auto generated when I pull a new invoice.

I got it to work

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.