/    Sign up×
Community /Pin to ProfileBookmark

Filtering a list of data

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;?>
&nbsp;</td>
<td class=”db_list_text” style=”padding-left:5px; padding-right:2px;”><!–DWLayoutEmptyCell–>&nbsp;</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–>&nbsp;</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–>&nbsp;</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–>&nbsp;</td>
</tr>
<tr>
<td height=”24″ colspan=”8″ valign=”top”> </tr>
</table></td>
</tr>
</table>
</td>
<?php } ?></td>[/CODE]

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

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@JS_FreakauthorApr 03.2007 — I'm sorry to bump this up but I'm quite desperate to get this sorted out. Can someone please help?

Thanks,

Karen
×

Success!

Help @JS_Freak spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...