I am a newbie to php, and in an attempt to create a script for my website I have come up with a problem that I am sure there is a simple answer to, I just can't find.
I have three tables in my data base.
- ID (primary)
- name [name of video]
- embed [html embed]
- Author [author name]
- thumburl [thumbnail url]
- description [descroiption]
- Active [is it active? y or n]
- contains category name and category id
- the only category I am currently working on it category 1
- conatins the Video id (vid) that corrosponds to cat ID (cid)
I am trying to get my code to find all video IDs that match the category ID 1 in the third table, and then from that output some of the information from table one. Here is my code.
Now, it may seem obvious to you, but I am a complete beginner and I do not know what I am doing wrong.
$result = mysql_query("SELECT * FROM vidcat WHERE cid='1'");
while($row = mysql_fetch_array($result))
$vid = $row['vid'];
$result2 = mysql_query("SELECT * FROM idname WHERE active='y'");
while($row2 = mysql_fetch_array($result2))
echo('<img src="'.$row2["thumburl"].'" /><br />');
echo ('<a href="video.php?id='. $vid .'">'. $row2["name"] .'</a><br />');
echo ('<b>'.$row2["Author"].'</b><br /><br />');
It is showing double of everything. The second one's link is different from the first one.