Hi guys,
Iam trying to make some code to check if author of the book is already exist on its authors table or not
so if he already exist : get his id number
if not exist : insert it to authors table then get its id number
i try something like this but its not work
$checkauthor = mysql_query("SELECT COUNT(*) FROM authors WHERE name='$author'")or sqlerr(__FILE__, __LINE__);
$resulto = mysql_fetch_row($checkauthor);
$result = $resulto['0'];
if($result >0)
{
$authorid=$result;
}
else
{
mysql_query("INSERT INTO authors (name) VALUES ($author)");
$newauthorp= mysql_query("SELECT id FROM authors WHERE name=".sqlesc($artrist)." LIMIT 1") or sqlerr(__FILE__, __LINE__);
$newauthor = mysql_fetch_row($newauthorp);