hi everyone :)
i have two tables (learningmaterial & evaluations) in mysql DB and i want to display all the learning material (from learningmaterial table ) and evaluations (if any) from evaluations table.. here is my code and i just want to ask how will i insert another select query inside the select query of learning material (i have learningmaterial_id in the evaluations table as a foreign key)
<?php
$con=mysql_connect($dbserver,$dbusername,$dbpassword);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($dbname, $con);
$result = mysql_query("SELECT * FROM learningmaterial WHERE (coursesid=".$cid.") ORDER BY sequence ASC");
echo "<table border='1' style='width:500px;'> <br />";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo " <h5>" . $row['title'] . "</h5>";
echo " <p>" . $row['description'] . "</p>";
if ($row['type'] === 'youtube video')
{
echo "<img src='graphics/youtube-icon.png'/>";
}
elseif ($row['type'] === 'vimeo video')
{
echo "<img src='graphics/vimeo-icon.png'/>";
}
elseif ($row['type'] === 'youtube audio')
{
echo "<img src='graphics/youtube-icon.png'/>";
}
elseif ($row['type'] === 'Flickr')
{
echo "<img src='graphics/flickr-icon.png'/>";
}
elseif ($row['type'] === 'Picasa')
{
echo "<img src='graphics/picassa-icon.png'/>";
}
elseif ($row['type'] === 'video')
{
echo "<img src='graphics/local-icon.png'/>";
}
elseif ($row['type'] === 'audio')
{
echo "<img src='graphics/local.png'/>";
}
elseif ($row['type'] === 'image')
{
echo "<img src='graphics/local.png'/>";
}
elseif ($row['type'] === 'ppt')
{
echo "<img src='graphics/local.png'/>";
}
elseif ($row['type'] === 'pdf')
{
echo "<img src='graphics/local.png'/>";
}
else
{
echo " ";
}
echo "</tr>";
}
and the query i want to run inside this query is:
$result1 = mysql_query("SELECT learningmaterial.id, evaluation.id,evaluation.name,evaluation.description,evaluation.learningmaterialid,evaluation.coursesid
FROM learningmaterial,evaluation
WHERE learningmaterial.id=evaluation.learningmaterialid");