Jump to content

mysql shows 5 digit ID; 00001 using zerofill, php query displays 1 digit; 1


greencoin

Recommended Posts

I'm trying to query the database, return the 5 digit ID + 1 and echo it into a text field. I have it all working but I'm losing my zeros! MySQL shows 00001 but my page displays 1.

 

The ID is stored in MySQL as mediumint(5), unassigned zerofill.

The php query is as follows;

$query2 = mysql_query("SELECT MAX(iid+1) AS maximum FROM gc_prod_info") or die(mysql_error());

 

Do I need to change my query to SELECT MAX(iid+00001) ...?

 

Any advice is appreciated. Thanks ~Rich

Link to comment
Share on other sites

try this

SELECT CAST(MAX(iid+1) AS VARCHAR) AS maximum FROM gc_prod_info

or

SELECT CAST(MAX(iid) AS VARCHAR)+1 AS maximum FROM gc_prod_info

but I am not sure..............

 

 

I'm not sure changing it to a VARCHAR will work as I'm pushing it back into MySQL as an INT when the form is submitted... ~Rich

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.