Code: Select all
<div id="blog_content" class="" style="height:90%; width:97%; border:5px solid #c0c0c0; background-color: #FFFFFF;"> <!--opens blog content-->
<?php
//address error handling
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);
//include the config file
require_once("config.php");
//Define the query. Select all rows from firstname column in members table, title column in blogs table,and entry column in blogs table, sorting in ascneding order by the title entry, knowing that the id column in mebers table is the same as the id column in blogs table.
$sql = "SELECT
blogs.title,blogs.entry,members.firstname,images.image,members.member_id
FROM
blogs
LEFT JOIN
members
ON
blogs.member_id = members.member_id
LEFT JOIN
images
ON
blogs.member_id = images.member_id
ORDER BY
blogs.title ASC
";
$query = mysql_query($sql);
if($query !== false && mysql_num_rows($query) > 0)
{
while(($row = mysql_fetch_assoc($query)) !== false)
{
echo
'<div id="blog_content1" style="float:left; position:relative;bottom:18px;left:13px; background-color: #FFFFFF; height:16.7%; width:100%; border:0px none none;"
<!--opens blog_content1 same as main center top 1 and 2 from index page everything scaled down by a factor of 3, heightwise-->
<div class="red_bar" style="height:3%; width:100%; border:1px solid #959595;"> <!--a-->
<div class="shade1" style="height:5px; width:100%; border:0px none none;"> </div>
<div class="shade2" style="height:5px; width:100%; border:0px none none"> </div>
<div class="shade3" style="height:5px%; width:100%; border:0px none none"> </div>
</div> <!-- closes red bar-->
<div class="content" style="height:28.3%; width:100%; border:0px none none;"> <!---->
<div class="slideshow" id="keylin" style="float:left; width:20%; border:0px none none;"> <!--a-->
<div><img name="" alt="" id="" height="105" width="105" src="picscript1.php?$picture = member_id" /></div>
</div> <!-- closes pic-->
<div class="content_text" style="float:right; position:relative;top:7px;left:0px; max-height:150px; width:78.5%; border-width:4.5px; border-bottom-style:solid; border-right-style:solid; border-color:#c0c0c0; "> <!--a-->';
echo "<h3>".$row['title']."</h3>";
echo "<p>" .$row['entry']."<br />".$row['firstname']."</p>";
echo
'</div> <!-- closes content text-->
</div> <!-- closes content-->
</div> <!-- closes blog_content1-->';
}
}
else if($query == false)
{
echo "<p>Query was not successful because:<strong>".mysql_error()."</strong></p>";
echo "<p>The query being run was \"".$sql."\"</p>";
}
else if($query !== false && mysql_num_rows($query) == 0)
{
echo "<p>The query returned 0 results.</p>";
}
mysql_close(); //Close the database connection.
?>
</div> <!-- closes blog content-->
The idea is to retrieve all the blog contributions(represented by the fields blogs.title and blogs.entry) from the database, alongside the contributing member (member.firstname) and the member's picture(images.image), using the member_id column to join the 3 tables involved, and outputs them on the webpage. The title, entry and firstname values are successfully displayed on the resulting page, indicating that the query worked.
Now here's the problem. In the img tag, I tried to pass a variable called $picture, into the picsript url (the picscript1.php file displayed below, contains a select query that outputs member pictures from database), and assigned it the value of the member_id in question. So I ended up with the following
<div><img name="" alt="" id="" height="105" width="105" src="picscript1.php?$picture = member_id" /></div>
Then in the select statement of picsript, I assinged the value $picture to the member_id field ending up with something like this
Code: Select all
$image = stripslashes($_REQUEST[picture]);
$rs = mysql_query("SELECT* FROM images WHERE member_id = 'picture' AND image_cartegory = 'main' ");
$row = mysql_fetch_assoc($rs);
$imagebytes = $row[image];
header("Content-type: image/jpeg");
print $imagebytes;Well the end end result is, no pictures got displayed. The blog entires and firstnames got displayed though. any hints as to what I need to do??