Have 2 tables - one for new titles and the other for authors.

I want to tag the "new titles" table with the "author" value if the author's name appears in list of new titles.

As you can see from my code, I don't have a clue what is wrong but its a type of query that I will be using a lot.

Suggestions where to start?

<?
	$sql="SELECT author FROM author_list ";
	
	$rs = mysql_query($sql);
	
	While($row = mysql_fetch_array($rs)){
	
	$id= ['author']; 
	
	$result = mysql_query("SELECT author, title from author_list, title_list WHERE title like '.$id.' ");
?>
Member Avatar for diafol

Have a look at JOIN.

Your DB could have the following:

AUTHORS
auth_id
name
surname
...

TITLES
title_id
auth_id
title
...

However,this setup would only allow a single author for each title
A better structure would be:

AUTHORS
auth_id
name
surname
...

TITLES
title_id
title
...

AUTHTITLE
auth_id
title_id
main_auth (tinyint, default=1)


What you need to retrieve title and author would be a JOIN. Read up on this in the mysql manual.

Hi

$id= ['author'];

replace the above code as below

$id= $row['author'];

Please give us your database structure for both tables.
To return you a correct working code.

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.