Menu

$message

Select one:

You have books to sell. Add your books to the school list.

You want to view the books you want to sell.

You sold your books. Remove your books from the school list.

You want to buy books. View the school list of books for sale.

This Online Book Sale will open on Friday, May 13 for book sales only. Purchases begin will open on Thursday, May 19. The Online Book Sale will close on September 1, 2018.

Email Questions or Comments

 

"; return $display_block ; } // close function menu // Time to select has not yet arrived // ---------------------------------------------- function regEarly() { $display_block = "

The Online Used Book Sale for 2018-2019 opens May 4, 2018 and closes September 1, 2018.

 

"; return $display_block; } // close function reject //on first login do this if (!$_POST[SNumber]){ // check date for ok time to view books see expirary above $chk = 'n'; if ($expiry_date > time()) {$chk = 'y';} if ($closing_date < time() ) {$chk = 'y';} if ($chk == 'y') { $display_block = regEarly(); }else { // after time can login //display login screen $display_block = "

 

Last Name:
Student Number: (6 digits)

 

The Incarnate Word Academy Online Book Sale is a place for IWA students to list used books to sell to other IWA students. Log on to add your books to the list and/or to view books that are for sale.

Click here for questions, comments or help

"; } } else{ if ($_POST[DoWhat] == 'Menu') { //open the connection $conn = mysqli_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); echo "
Welcome to IWA Online Used Book Sale Portal.

 

"; //pick the database mysqli_select_db($conn, 'incarnat_Used_Books'); //create the SQL statement $sql = "SELECT * FROM `students`"; //execute the SQL statement $resultm = mysqli_query($conn, $sql) or die(mysqli_error($conn)); //go through each row to match student in database $hit = 'n'; while ($newArray = mysqli_fetch_array($resultm)){ if ($newArray['id']== $_POST[SNumber] && strtolower($newArray['last'])== strtolower($_POST[LName])){ $SNumber = $_POST[SNumber]; $student_name = $newArray['first']; $student_last = $newArray['last']; $message = "Hello, ".$student_name."!"; $hit = 'y'; $display_block = menu($SNumber, $student_name, $student_last, $message); } // close if match } // close while if ($hit == 'n') { header("Location: usedbooks.php"); exit; } // close if no hit } // close if Menu if ($_POST[DoWhat] == 'Add') { $SNumber = $_POST[SNumber]; $student_name = $_POST[student_name]; $student_last = $_POST[student_last]; $display_block = "

Seller Email Address

 

Directions:

Be sure your email address is in the box below. It must be typed here accurately in order to receive offers for your books. Then click "Submit".

Your email address:

"; } // close if Add if ($_POST[DoWhat] == 'Sell') { $SNumber = $_POST[SNumber]; $student_name = $_POST[student_name]; $student_last = $_POST[student_last]; $email = $_POST[email]; $count = 0; //open the connection $conn = mysqli_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); echo "
Welcome to IWA Online Used Book Sale Portal.

 

"; //pick the database mysqli_select_db($conn,'incarnat_Used_Books'); $display_block = "

Selling Books

Directions:

  1. For books that you want to sell, check the box to the left of each book title and type in the condition of the book.

  2. Excl new or like new, in excellent condition, pages are intact and not marred by notes or highlighting
    Good has been used but remains in clean condition, all pages are intact, the spine may show signs of wear, pages include limited notes and hightlighting
    Fair readable copy, all pages and cover are intact, pages include considerable notes in pen or highlighter but notes do not obscure the text
    Poor bad copy, barely sellable, no missing pages, cover may or may not be intact

  3. Click on the ISBN link next to course name for an online price comparison.
  4. Next, list your selling price and the condition of the book then click "Submit" at the bottom of this page.
  5. You will be contacted via email when a person is interested in buying your book.
  6. Current student sellers will need to arrange a meeting place and time for the transaction. If current student sellers are selling books to new students, they are encouraged to complete those transactions on Thursday, May 24, 2018 at the IWA Used Uniform & Used Book Exchange. Students should talk to their parents to see if a check is an acceptable form of payment.
  7. Your books will continue to be listed on this website until you remove them from the list. When any of your books sell, return to this site and remove the sold book from your list.
"; //create the SQL statement $sqls = "SELECT DISTINCT section FROM courses "; //execute the SQL statement $results = mysqli_query($conn,$sqls) or die(mysqli_error($conn)); //go through each row to match section in database while ($arrayresults = mysqli_fetch_array($results)){ $dept = $arrayresults['section']; $display_block .= "

 

$dept

"; //create the SQL statement $sqlc = "SELECT DISTINCT isbn, ctitle FROM courses WHERE section = '$dept' "; //execute the SQL statement $crs = mysqli_query($conn,$sqlc) or die(mysqli_error($conn)); //go through each row to match in database while ($crsinfo = mysqli_fetch_array($crs)){ $coursename = $crsinfo['ctitle']; $booknum = $crsinfo["isbn"]; $display_block .= "

$coursename | ISBN: $booknum

"; $sqlbooks = "SELECT book FROM courses WHERE section = '$dept' and isbn = '$booknum' and ctitle='$coursename' "; //execute the SQL statement $resultbooks = mysqli_query($conn, $sqlbooks) or die(mysqli_error($conn)); //go through each row to match student in database while ($row = mysqli_fetch_array($resultbooks)){ $book = $row['book']; $count = $count + 1; $display_block .= " "; } // close while course $display_block .= "

Book Title

Condition (Excl, Good, Fair, Poor)

Selling Price

$book

$

 

"; } // close while sections } // close while sections $display_block .= "

 

 

"; } // close if Sell if ($_POST[DoWhat] == 'MenuSell') { //connect to server and select query $conn = mysqli_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); echo "
Welcome to IWA Online Used Book Sale Portal.

 

"; //pick the database mysqli_select_db($conn,'incarnat_Used_Books'); $total = $_POST[count]; $SNumber = $_POST[SNumber]; $email = $_POST[email]; $student_name = $_POST[student_name]; $student_last = $_POST[student_last]; $count=0; while ($count < $total) { $count++ ; if($_POST['pbook'.$count] != "") { $book = ($_POST['book'.$count]); $bookcondition = $_POST['cbook'.$count]; $bookprice = $_POST['pbook'.$count]; $sql = "INSERT INTO book VALUES ( '$SNumber', '$student_name', '$student_last', '$email', '$book', '$bookcondition', '$bookprice' )"; mysqli_query($conn,$sql) or die(mysqli_error($conn)); $message = "Books have been added to your list!"; } // close if } // close while $display_block = menu($SNumber, $student_name, $student_last, $message); } // close if MenuSell if ($_POST[DoWhat] == 'List') { //open the connection $conn = mysqli_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); echo "
Welcome to IWA Online Used Book Sale Portal.

 

"; //pick the database mysqli_select_db($conn,'incarnat_Used_Books'); //create the SQL statement $sql = "SELECT * FROM `book` WHERE id = $_POST[SNumber]"; //execute the SQL statement $resultlist = mysqli_query($conn, $sql) or die(mysqli_error($conn)); $SNumber = $_POST[SNumber]; $student_name = $_POST[student_name]; $student_last = $_POST[student_last]; $display_block = "

Your Listed Books

The following are books you have listed on the Used Book Sale list.

 

"; while ($row = mysqli_fetch_array($resultlist)){ $book = $row['book']; $condition = $row['condition']; $price = $row['price']; $display_block .= " "; } $display_block .= "

Book Title

Book Condition

Book Price

$book $condition \$ $price

 

 

"; } // close if List if ($_POST[DoWhat] == 'BackToMenu') { $SNumber = $_POST[SNumber]; $student_name = $_POST[student_name]; $student_last = $_POST[student_last]; $message = ""; $display_block = menu($SNumber, $student_name, $student_last, $message); } // close if BackToMenu if ($_POST[DoWhat] == 'Remove') { //open the connection $conn = mysqli_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); echo "
Welcome to IWA Online Used Book Sale Portal.

 

"; //pick the database mysqli_select_db($conn,'incarnat_Used_Books'); //create the SQL statement $sql = "SELECT * FROM `book` WHERE id = $_POST[SNumber]"; //execute the SQL statement $resultlist = mysqli_query($conn, $sql) or die(mysqli_error($conn)); $SNumber = $_POST[SNumber]; $student_name = $_POST[student_name]; $student_last = $_POST[student_last]; $display_block = "

Remove Listed Books

The following are books you have listed on the Used Book Sale list. Click on the check box next to each title that you would like to remove from the list then click the 'Submit' button.

 

"; $num = 0; while ($row = mysqli_fetch_array($resultlist)){ $num++; $book = $row['book']; $condition = $row['condition']; $price = $row['price']; $display_block .= " "; } $display_block .= "
 

Book Title

Book Condition

Book Price

$book $condition \$ $price

 

or

 

"; } // close Remove if ($_POST[DoWhat] == 'Out') { $num = $_POST[num]; $SNumber = $_POST[SNumber]; $student_name = $_POST[student_name]; $student_last = $_POST[student_last]; //open the connection $conn = mysqli_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); echo "
Welcome to IWA Online Used Book Sale Portal.

 

"; //pick the database mysqli_select_db($conn,'incarnat_Used_Books'); //create the SQL statement $sql = "SELECT * FROM `book` WHERE id = $_POST[SNumber]"; //execute the SQL statement $resultlist = mysqli_query($conn, $sql) or die(mysqli_error($conn)); while ($row = mysqli_fetch_array($resultlist)){ $book = $row['book']; $condition = $row['condition']; $price = $row['price']; $id =$row['id']; $count = 0; While ($count < $num) { $count++; $bookn = $_POST['book'.$count]; $bookc = $_POST['bookc'.$count]; $bookp = $_POST['bookp'.$count]; if ($book == $bookn && $condition == $bookc && $price == $bookp ) { $sql = "INSERT INTO sold VALUES ( '$id', '$book', '$condition', '$price' )"; mysqli_query($conn,$sql) or die(mysqli_error($conn)); $sql2 = "DELETE FROM book WHERE id='$SNumber'AND book='$book' "; mysqli_query($conn,$sql2) or die(mysqli_error($conn)); } // close if } // close while $count } // close while $row $message = "Your book or books have been removed from the school list."; $display_block = menu($SNumber, $student_name, $student_last, $message); } // close Out if ($_POST[DoWhat] == 'View') { $SNumber = $_POST[SNumber]; $student_name = $_POST[student_name]; $student_last = $_POST[student_last]; $counter = 0; //open the connection $conn = mysqli_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); echo "
Welcome to IWA Online Used Book Sale Portal.

 

"; //pick the database mysqli_select_db($conn,'incarnat_Used_Books'); //execute the SQL statement $results = mysqli_query($conn,"SELECT * FROM courses ORDER BY ctitle ") or die(mysqli_error($conn)); //store array in temp array for re-use $cnt = 0; while ($arrayresults = mysqli_fetch_array($results)){ $cnt++; $section[$cnt] = $arrayresults['section']; $isbn[$cnt] = $arrayresults['isbn']; $ctitle[$cnt] = $arrayresults['ctitle']; $book[$cnt] = $arrayresults['book']; } $resultc = mysqli_query($conn,"SELECT DISTINCT section FROM courses ") or die(mysqli_error($conn)); $display_block = "

Books for Sale - Choose Books

Place a check in the box next to each book you are interested in then press 'Submit' at the bottom of the page.

 

"; while ($arrayresultc = mysqli_fetch_array($resultc)){ $dept = $arrayresultc['section']; $display_block .= " "; $i = 0; while ($i < $cnt) { $i++; if ($section[$i] == $dept){ $booknum = $isbn[$i]; $cttl = $ctitle[$i]; $bk = $book[$i]; $counter++; $display_block .= " "; } // close if } // close while $display_block .= "

$dept

$cttl ISBN:$booknum $bk
"; } // close while dept $display_block .= "

 

 

Email Questions or Comments

 

"; } // close View if ($_POST[DoWhat] == 'ViewChoice') { $SNumber = $_POST[SNumber]; $student_name = $_POST[student_name]; $student_last = $_POST[student_last]; $endcount = $_POST[endcount]; //open the connection $conn = mysqli_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); echo "
Welcome to IWA Online Used Book Sale Portal.

 

"; //pick the database mysqli_select_db($conn,'incarnat_Used_Books'); //execute the SQL statement $results = mysqli_query($conn,"SELECT * FROM book ORDER BY book") or die(mysqli_error($conn)); //store array in temp array for re-use $cnt = 0; while ($arrayresults = mysqli_fetch_array($results)){ $cnt++; $first[$cnt] = $arrayresults['first']; $last[$cnt] = $arrayresults['last']; $email[$cnt] = $arrayresults['email']; $book[$cnt] = $arrayresults['book']; $condition[$cnt] = $arrayresults['condition']; $price[$cnt] = $arrayresults['price']; } $display_block = "

Books for Sale - Your Selections

The book titles you chose are listed below. You will find the email address of a IWA student selling that book along with the condition and asking price for the book. Click on the email address to get in touch with the person selling the book.

 

BUYER BEWARE!

It is advised that students have their class schedule on hand for reference when buying books. When purchasing used books, be sure to check that you are getting the correct version for the corresponding academic year and that the condition of the book fits its description. The IWA booklist is located on the IWA website.

It is the buyer's responsibility to have correct change for all purchases. It is the seller's choice to accept checks.

Sellers of books are listed below with e-mail contact information. Buyers need to contact sellers to arrange meeting place and time for transaction.

 

 

"; $count = 0; while ($count < $endcount) { $count++; $bookn = $_POST['book'.$count]; if ($bookn != "") { $display_block .= " "; $x = 0; while ($x < $cnt) { $x++; if ($book[$x] == $bookn) { $display_block .= " "; } // close if $bookx } // close while $x $display_block .= " "; } // close if $bookn } // close while $count $display_block .= "

$bookn

Name Email Condition Price
$first[$x] $last[$x] $email[$x] $condition[$x] \$ $price[$x]
 

 

 

"; } // close ViewChoice } // close else of first post check if (empty($_POST[DoWhat])) { $SNumber = $_POST[SNumber]; $student_name = $_POST[student_name]; $student_last = $_POST[student_last]; $counter = 0; //open the connection $conn = mysqli_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); echo "
Welcome to IWA Online Used Book Sale Portal.

 

"; //pick the database mysqli_select_db($conn,'incarnat_Used_Books'); //execute the SQL statement $message = "Please make a selection."; $display_block = menu($SNumber, $student_name, $student_last, $message); //no radio selected at main menu } ?> IWA Online Used Book Sale Portal

Online Used Book Sale Portal

 

Program written by Denise Stasio with special thanks to David Sims.

Incarnate Word Academy has provided this program to assist in the selling and purchasing of textbooks. IWA is not taking part in financial transactions, as this is between buyer and seller. In addition, IWA will not be held liable for any off campus arrangements between buyer and seller.