I looked at the print_r() function, I never knew what it was but it looks like it could be useful. Thanks for that.

OK everything is working as it should now: species, year, sex, price and the correct subcat id are being entered into the table as expected. But on initial page load it still gives the same error which disapears after the first form submit.It doesnt come back if you keep submitting more animals to the db. Like I said, all seems to be working fine but its not nice seeing the error at the start.
Any ideas why this would happen?

It seems to be sorted now. I had initially changed

   $r = mysql_query("SELECT subcat_id, subcategory_label FROM subcategories ORDER BY cat_id");

to ORDER by subcat_id as the above put 'other lizards' above the list of named categories instead of after. But after changing it back, the error did not appear at all. I can live with one category being out of sequence!

Member Avatar for diafol

You can set a ranked order by altering your subcat table:

subcat_id | subcat_label | subcat_order | cat_id

The subcat_order is an integer or tinyint field, so you can set the order you want them to appear in.

You can then do

$r = mysql_query("SELECT subcat_id, subcategory_label FROM subcategories ORDER BY subcat_order");

Thanks for all your help on this, its greatly appreciated. This is solved now.

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.