php - how to check a empty table already in database -



php - how to check a empty table already in database -

this question has reply here:

mysql check if table exists without throwing exception 8 answers

i creating admin panel of site.when admin come in category , table of same category name create in database, fields table same.. in starting admin come in lot of category..then how can check table created in database..because tables empty.

i trying code

<?php $con = mysql_connect("localhost","root",""); if (!$con) {die('could not connect: ' . mysql_error());} $sql="select * admin";//(for trial im changing name manuaaly) $result=@mysql_query($sql); if (!$result) { echo "no table exists"; } else { echo "yes"; } ?>

but in show "no table exists", if table in db.. how can solve this..

do not create separate table each category! create one, set of fields , 1 category name (or category id, depends on database schema).

that's basics of how databases works.

thus have run regular query check if such category name exists:

select id categories name = 'name check';

php mysql

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -