Hey all,
I have two tables. One holds comments and the other holds the question/picture info.
What I want to do is if a logged in user has already commented on a picture, for that picture to not display (there is a drop down that allows them to sort by male/female). And if all the questions in the database are answered for the user to see smthg that says like "no more records". I know this should be so easy for me but i'm having the hardest time with this and i dont know why!
I know none of this is secure either that's my next step once i get the basic functionality going. (i have to do some research and reading on how to prevent injunctions) here's what I have... it still displays all the questions that have already been answered AND not answered by the user.
I've tried moving the brackets around to include the second query, but that doesn't work either.PHP Code:
<?php
$getqry88 = "select distinct(questid) from comments where commid = $id";
$getres88 = mysql_query($getqry88)or die(mysql_error());
$getrows88=mysql_num_rows($getres88);
if($getrows88 > 0){
while($getarray88=mysql_fetch_array($getres88)){
$hqid12 = $getarray88['questid'];
}}
//if male only
if ($_REQUEST['sort'] == 'male')
{
$getqry = "select * from questions where approved = 'yes' and status = 'active' and quest_gender = 'male' and getquest_counter != $hqid12 order by rand()";
}
//if female only
if ($_REQUEST['sort'] == 'female')
{
$getqry = "select * from questions where approved = 'yes' and status = 'active' and quest_gender = 'female' and getquest_counter != $hqid12 order by rand()";
}
$getres = mysql_query($getqry)or die(mysql_error());
$getrows=mysql_num_rows($getres);
if($getrows > 0){
while($getarray=mysql_fetch_array($getres)){
$pic = $getarray['pic1'];
$qid2 = $getarray['getquest_counter'];
$question = $getarray['question'];
}
}
else
echo "no records";
?>
any help would be greatly appreciated!



Reply With Quote
Bookmarks