Skip to content
Advertisement

double data on mysql

I use the php operator && to select multiple data so that there is no duplication on mysql. Does the code that I use below run fine? Is there a more simple use of PHP operators?

JavaScript

Advertisement

Answer

Upgrade to mysqli, I’ll recommend object-oriented syntax because it is nicer to work with.

In accordance with the best practice of “minimize calls to the database”, I’ll condense your three queries into a single, united SELECT call then check for a non-0 result.

My untested suggestion using mysqli’s object-oriented syntax (I did test the SELECT query in PHPMyAdmin):

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement