hi....i have some problem here...i'm making a form for ordering...what i want is when user click on form ordering button, there will be a form with reference number echo from database..in database i set the reference number as primary key and auto increment..somebody can help me to solve this problem??

Recommended Answers

All 4 Replies

If the auto incremented value must match whats in the database then you will need to insert a row and then get the NEW ID (via ajax probably) using PHP's

echo mysql_insert_id();

You will therefore use UPDATE statements to modify the newly created row

i've try it...but why i get value 0 in reference number in the order form?

Does it have to be a pre-made random id?
or can you do like this:

$randId = rand(1234ab,12345ab);
<form>
<input type="hidden" name="randomid" value="<?php echo $randId ?>"> 
</form>

and then insert it to mysql?
Member Avatar for diafol

ezra, could you show your code. We need to see what you're doing in order to see where you've got a problem. Otherwise I'd say look at line 98 and add a ;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.