Okay, am creating a checklist of books (two actually). This displays their name, price, rarity, and a checkbox. I have one list that shows all books that have been Read. One shows all books that have Not been read. In order to do this I have two tables.
One is called collector_books. This contains approx 1400 books, their prices, their rarity (just a number...ranking system for rarity), and an sid number.
Then I have a second table, called collector_books_read. This contains only two things sid and uid. This table is what will be storing the data to determine which books a user has read.

The coding below is what I am using to display what books a user has read or has not read. It works fine for displaying what books a user Has read. However, the modification I did to show what books a user has Not read, does not work. The modification is what I show below. The only thing I changed was the $query statement. When I want to show what books I have read, I have "WHERE A1.sid = A2.sid"...that works. I thought changing the Equals to Not Equals would be all I have to do to get it to work show ones that I have Not read...however, instead it displays all the books twice, with the exception of the ones I have read (the ones I have read only show up once). To me, this shows that it is SEMI-working because it is eliminating the ones I have read...but for some reason shows the entire first table again.

I hope that all made sense...I know, very wordy. Don't mind the checkboxes, I haven't gotten to the stage where I can actualy have users check stuff off to move it from unread to read...or vise-versa.

Help is appreciated. I'm quite new to all this php/mysql stuff so please talk in lamenst(sp?) terms.

<html>

<body>

<?php

global $user;

$db = mysql_connect("localhost", "collin","MYPASSWORD");

mysql_select_db("colliny2k_neo",$db);

$query="SELECT * FROM collector_books A1, collector_books_read A2 WHERE A1.sid <> A2.sid  AND A2.uid = $user->uid ORDER BY A1.book ASC";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b><center>Book Collector Checklist</center></b><br>";
echo "<table border=1 cellpadding=0 cellspacing=0><br>";
echo "<tr><td>Book</td><td>Rarity</td><td>Price</td><td>Read</td></tr>";

$i=0;
while ($i < $num) {
	$book=mysql_result($result,$i,"book");
	$rarity=mysql_result($result,$i,"rarity");
	$price=mysql_result($result,$i,"price");
	$sid=mysql_result($result,$i,"sid");
	
	$checkbox="<input type=checkbox name=checkbox value=$sid>";
	echo "<tr><td>$book</td><td>$rarity</td><td>$price</td><td>$checkbox</td></tr>";
	
	$i++;
}
echo "</table>";

?>

</body>
</html>

Comments

khoogheem’s picture

Are you trying to display something like:

Books
A
B
C
D
E

Books Read:
A
B
C

Books not read:
D
E

They they check off which ones they just read out of the Books not read?

Seems like if that is it you could just get all books in one sql call.
Then just make a call on the books read table.
then something like

$readbooks = db_fetch_results(sql of books read);
foreach ($allbooks = db_fetch_results(sql of all books)){
  do an if readbooks->sid == allbooks->sid
put in a array for books_read
else put in array for books_not_read
}

I am sure there is some cleaner ways.. but this is off the top of the head right now