Hi there!
Can someone please help a damsel in distress. I have a database system set up where the administrator can upload articles relevant to specific areas in the country. Members can then log in and go to the downloads page to download these articles. My problem is this: I can get it to display the complete list of articles but not those specific to the members’ area. I have two tables in my MySQL database: files and members. Both tables have a field called areas. I used this code to select the info from the database:
[CODE]<?php
$query = “SELECT id, name, description, area FROM files WHERE area= “.$_SESSION[‘area’];
$result = mysql_query($query) or die(‘Error, query failed’);
if(mysql_num_rows($result) == 0)
{
echo “Database is empty <br>”;
}
else
{
while(list($id, $name, $description, $area) = mysql_fetch_row($result)) {
?>
<tr <?php if (is_int($i/2)) print “bgcolor=”#C6E4FD””; ?>>
<td height=”27″ class=”body-text-np” style=”padding-left:5px; padding-right:2px;”><img src=”../images/icon_update.gif” width=”16″ height=”16″></td>
<td class=”db_list_text” style=”padding-left:5px; padding-right:2px;”><?= $name;?>
</td>
<td class=”db_list_text” style=”padding-left:5px; padding-right:2px;”><!–DWLayoutEmptyCell–> </td>
<td class=”db_list_text” style=”padding-left:5px; padding-right:2px;”>
<?= $description;?></td>
<td class=”db_list_text” style=”padding-left:5px; padding-right:2px;”><!–DWLayoutEmptyCell–> </td>
<td class=”db_list_text” style=”padding-left:5px; padding-right:2px;”><a href=”downloads.php?id=<?= $id; ?>”>Click Here</a></td>
<td class=”db_list_text” style=”padding-left:5px; padding-right:2px;”><!–DWLayoutEmptyCell–> </td>
<td class=”db_list_text” style=”padding-left:5px; padding-right:2px;”><span class=”db_list_text” style=”padding-left:5px; padding-right:2px;”>
<?= $area;?>
</span></td>
</tr>
<?php $i++; } ?>
<tr align=”right”>
<td height=”24″ colspan=”8″ valign=”top” class=”db_list_text”><!–DWLayoutEmptyCell–> </td>
</tr>
<tr>
<td height=”24″ colspan=”8″ valign=”top”> </tr>
</table></td>
</tr>
</table>
</td>
<?php } ?></td>
It looks right to me. I basically want the code to compare the area of the logged in member, ie the session area (the username and password is also in the members table), to the article area and only display those. How do I do this?
Anyone please help!!
Karen