Hello all,
I need help with a php code. I am stuck and I will really appreciate if you can help me.
I have one page that displays a random project image and project title out of a phpmyadmin database.
Code for this page:
<?php
$result = mysql_query("SELECT id, project_title, img_bin FROM featured_projects WHERE W_C = 1 AND status = 1 ORDER BY Rand() LIMIT 1");
if (mysql_num_rows($result) == 0) { echo "<p>Sorry. We couldn`t find any projects.</p>";}
else {
while( $c = mysql_fetch_object($result)) {
$image = ($c->img_bin) ? "<img src=\"img.php?id={$c->id}&table=featured_projects\" "
."border=\"0\" alt=\"[image]\" />" : "";
printf("<div class=\"featured\">
<h3>%s</h3>
<p>$image</p>
</div>
",
$c->project_title, $c->project_title, $c->project_title, $c->project_title
);
}
}
?>
When I click on the active image (selected randomly) in the first page, I want to go to another page and show a more detailed information about the selected project. Here is the code I write for this:
<?php
$result = mysql_query("SELECT id, project_title, project_description , related_manager, team_members, img_bin FROM featured_projects WHERE DM = 1 AND status = 1");
if (mysql_num_rows($result) == 0) { echo "<p>Sorry. No news to report yet.</p>";}
else {
while( $c = mysql_fetch_object($result)) {
$image = ($c->img_bin) ? "<img src=\"../img.php?id={$c->id}&table=featured_projects\" "
."border=\"0\" alt=\"[image]\" />" : "";
print <<<END
<table width="690" border="0" cellpadding="0" cellspacing="20">
<tr>
<td width="550" align="left">
<h2>$c->project_title </h2><br>
<b>Manager: </b> $c->related_manager <br>
<b>Team Members: </b> $c->team_members <br>
$c->project_description <br>
</td>
<td width="140" valign="top">
$image
</td>
</tr>
</table>
END;
}
}
?>
My only problem is, the second code shows information about all of the projects, not the selected one.
How can I do that?
Thanks in advance,