Jump to content

cty

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

cty's Achievements

Member

Member (2/5)

0

Reputation

  1. <?php session_start(); echo'Welcome<font size=5> '; echo $_SESSION['valid_user']; echo'</font><br />'; echo'<p>'; echo'This is My Account page'; $db=new mysqli('localhost','root',''); if (mysqli_connect_errno()) { die( 'Connect failed: ' . mysqli_connect_error() ); } $db->select_db('test') or die( 'select_db failed: '.$db->error ); $x=$_SESSION['valid_user']; $query="select userid from user where username='$x'"; $result=$db->query($query) or die('query failed'.$db->error); $row=$result->fetch_assoc(); $y=$row['userid']; $query='SELECT * FROM buybook,book'." WHERE userid='$y'". "and book.bookid=buybook.bookid"; $result=$db->query($query) or die( 'query failed: '.$db->error ); echo"<p><font color=blue> Book I Buy</font></p>"; if(mysqli_num_rows($result)>0) { echo"<table border=1 align=center width=80% bgcolor=#99CCFF>"; echo "<tr>"; echo"<td align=center> ISBN </td>"; echo "<td align=center> TITLE </td>"; echo "<td align=center> PRICE </td>"; echo"<td align=center> CONDITION</td>"; echo "<td align=center> DATE</td>"; echo "<td align=center> TIME</td>"; echo "<td align=center>SELLER</td>";//test echo"</tr>"; while($row=mysqli_fetch_assoc($result)) { echo"<tr>"; echo"<td align=center>".$row['isbn']."</td>"; echo"<td align=center>".$row['title']."</td>"; echo"<td align=center>RM&nbsp".$row['price']."</td>"; echo"<td align=center>".$row['condition']."</td>"; echo"<td align=center>".$row['buydate']."</td>"; echo"<td align=center>".$row['buytime']."</td>"; $k=$row['isbn']; $query='SELECT userid FROM sellbook,book'." WHERE isbn='$k'". "and book.bookid=sellbook.bookid"; $result=$db->query($query) or die('query failed'.$db->error); $row=$result->fetch_assoc(); $s=$row['userid']; $query='SELECT username FROM user'." WHERE userid='$s'"; $result=$db->query($query) or die('query failed'.$db->error); $row=$result->fetch_assoc(); echo"<td align=center>".$row['username']."</td>"; echo"</tr>"; } echo"</table>"; } else { echo"No data found!"; } ?> --------------------------------------- Problem: The $row['username'] unable to display when $row=mysqli_fetch_assoc($result) are more than one. For example, If the result is only one,then the $row['username'] able to display, BUT, when the result is more than one,$row['username'] cannot be show. In addtion, $row['isbn']$row['title']$row['price'] $row['condition']$row['buydate']$row['buytime'] only display once, meaning,if search result have 3 record,only one record will be shown , and the username wil totally gone! Can any one able to edit for me?
  2. cty

    SQL syntax

    can anyone help me to edit it to correct form? $query="insert into book(buyer) values('".$x."')where id=".$book;
  3. can anyone help me to edit my coding?
  4. can show me how to edit the code?
  5. hi,i try my code like this,but have warning! Warning: in_array() [function.in-array]: Wrong datatype for second argument in C:\testshop2\cart.php on line 17 Fatal error: [] operator not supported for strings in C:\testshop2\cart.php on line 19 PHP Warning: in_array() [function.in-array]: Wrong datatype for second argument in C:\testshop2\cart.php on line 17 PHP Fatal error: [] operator not supported for strings in C:\testshop2\cart.php on line 19 -------------------------------------------------------------------- switch ($action) { case 'add': if(count($cart) > 0) { if(!in_array($_GET['id'], $cart)) { $cart[] = $_GET['id']; } else { echo "you already order the book!"; } } else{ $cart = $_GET['id']; } break; Please try your best to help me.Thank you
  6. my Question: I am using MySQL+PHP5+IIS (*NOTE:i just let the user to buy each book for ONE unit only.) step 1(correct): when i click "Add to cart"(index.php) for the book "ABC" , a message was shown in (cart.php):"You have 1 item in your shopping basket" when i click the "Add to cart"(index.php) for the book "ABC" AGAIN, a message shown including:"You have 1 item in your shopping basket" and "you already order the book!" step 2(have bugs/error occur): when i click "when i click "Add to cart"(index.php) for the book "XYZ" , a message was shown in (cart.php):"You have 2 item in your shopping basket" when i click the "Add to cart"(index.php) for the book "ABC" AGAIN, a message shown including:"You have 3 item in your shopping basket" (*the item number will continue increase) what i want is:i hope i can get the message "You have 2 item in your shopping basket" Also,will shown "you already order the book!" when i try to add the same item again! The coding part that i suspect make the error occur as below: case 'add': if ($cart){ if($cart!=$_GET['id']){ $cart .= ','.$_GET['id']; } else{ echo "you already order the book!"; } } else{ $cart = $_GET['id']; } can anyone help me to edit it? Table Scheme: CREATE TABLE books( id int auto_increament, title varchar author varchar price decimal PRIMARY KEY(id) ); USE books; INSERT INTO books VALUES(1,'ABC','kelly','25.00'); INSERT INTO books VALUES(2,'XYZ','john','80.00'); EDITED BY WILDTEEN88: Please note your post has been moderated. All code snippets have been attached as files. Please use the code tags when posting code snippets. When posting code for whole files attach the files to your post instead. [attachment deleted by admin]
  7. Error shown: Query (line 50) failed:You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 ----------------------------------------- My first problem: How am i going to eidt this query to a correct form? $query="delete from cart where bookid =$bookid"; ---------------------------------------- My second problem(main problem): Why the book price and the total price always shown 0?(*When i click on "buy). ------------------------------------------------- Below are my code: //product.php <?php include("db.php"); $db=new mysqli('localhost','root','','test'); if(mysqli_connect_errno()) { die('Connect failed(line 7):'.mysqli_connect_error()); } $db->select_db('test') or die ('Select_db failed(line 14):'.$db->error); $query="select * from book order by title asc"; $result = $db->query($query) or die('Query (line 18) failed:'.$db->error); ?> <?php while($row =$result->fetch_assoc()) { ?> <table border=1 width=80% bgcolor="pink"> <tr> <td width=20%> <font face="verdana" size="2" color="black" > ISBN : </font> </td> <td > <font face="verdana" size="2" color="black"> <?php echo $row["isbn"]; ?> </font> </td> </tr> <tr> <td width=20%> <font face="verdana" size="2" color="black"> TITLE: </font> </td> <td > <font face="verdana" size="2" color="black"> <?php echo $row["title"]; ?> </font> </td> </tr> <tr> <td width=20%> <font face="verdana" size="2" color="black"> Author : </font> </td> <td > <font face="verdana" size="2" color="black"> <?php echo $row["author"]; ?> </font> </td> </tr> <tr> <td width=20%> <font face="verdana" size="2" color="black"> Description : </font> </td> <td > <font face="verdana" size="2" color="black"> <?php echo $row["description"]; ?> </font> </td> </tr> <tr> <td width=20%> <font face="verdana" size="2" color="black"> Condition : </font> </td> <td > <font face="verdana" size="2" color="black"> <?php echo $row["condition"]; ?> </font> </td> </tr> <tr> <td width=20%> <font face="verdana" size="2" color="black"> Price(RM) : </font> </td> <td > <font face="verdana" size="2" color="black"> <?php echo $row["price"]; ?> </font> </td> </tr> <td > <font face="verdana" size="2" color="black"> <a href=cart.php?action=add_item&bookid=<?php echo $row["bookid"];?>>Buy</a> </font> </td> </tr> <br /> </table> <?php }?> <tr> <td > <hr size="2" color="red" NOSHADE> </td> </tr> <tr> <td > <font face="verdana" size="5" color="black"> <a href="cart.php"> View Your Shopping Cart &gt;&gt;</a> </font> </td> </tr> </table> </body> </html> ----------------------------------------------------- //kelly.php <?php function AddItem($bookid){ $db=new mysqli('localhost','root','','test'); if(mysqli_connect_errno()) { die('Connect failed:'.mysqli_connect_error()); } $db->select_db('test') or die ('Select_db failed:'.$db->error); $query="select count(*) from cart where bookid = '$bookid'"; $result=$db->query($query) or die('Query line 17 failed:'.$db->error); $row =$result->fetch_row(); $numRows = $row[0]; if($numRows == 0) { $query="insert into cart(cookieId, bookid) values('" . GetCartId() . "', '$bookid')"; $result=$db->query($query) or die('Query line 29 failed:'.$db->error); } else { echo "The book already in your shopping cart."; echo "<br />"; } } function RemoveItem($bookid){ $db=new mysqli('localhost','root','','test'); if(mysqli_connect_errno()) { die('Connect failed:'.mysqli_connect_error()); } $db->select_db('test') or die ('Select_db failed(line 53):'.$db->error); $query="delete from cart where bookid =$bookid"; $result=$db->query($query) or die('Query (line 50) failed:'.$db->error); } function ShowCart( ){ $db=new mysqli('localhost','root','','test'); if(mysqli_connect_errno()) { die('Connect failed:'.mysqli_connect_error()); } $db->select_db('test') or die ('Select_db failed:'.$db->error); $query="select * from cart inner join book where cart.bookid = book.bookid and cart.cookieId = '" . GetCartId() . "'order by book.title asc"; $result=$db->query($query) or die('Query line 78 failed:'.$db->error); $totalCost=0; while($result->fetch_assoc()) { $totalCost +=$row["price"]; ?> <td width="55%" height="25"> <font face="verdana" size="1" color="black"> <?php echo $row["title"]; ?> </font> </td> <td width="20%" height="25"> <font face="verdana" size="1" color="black"> $<?php echo number_format($row["price"], 2); ?> </font> </td> <td width="10%" height="25"> <font face="verdana" size="1" color="black"> <a href=cart.php?action=remove_item&bookid=<?php echo $row["bookid"];?>>Remove</a> </font> </td> </tr> <br /> <?php } ?> <tr> <td width="100%" colspan="4"> <hr size="1" color="red" NOSHADE> </td> </tr> <tr> <td width="70%" colspan="2"> <font face="verdana" size="1" color="black"> <a href="products.php">&lt;&lt; Keep Shopping</a> </font> </td> <td width="30%" colspan="2"> <font face="verdana" size="2" color="black"> <b>Total: $<?php echo number_format($totalCost, 2); ?></b> </font> </td> </tr> <?php } ?> ------------------------------------------------- //db.php <?php function GetCartId() { if(isset($_COOKIE["cartId"])) { return $_COOKIE["cartId"]; } else { session_start(); setcookie("cartId", session_id(), time() + ((3600 * 24) * 30)); return session_id(); } } ?> ------------------------------------------------------ //cart.php <?php include("kelly.php"); include("db.php"); ?> <?php switch($_GET["action"]) { case "add_item": { AddItem($_GET["bookid"]); ShowCart(); break; } case "remove_item": { RemoveItem($_GET["bookid"]); ShowCart(); break; } default: { ShowCart(); } } ?> ---------------------------------------------//end
  8. $totalCost=0; while($row = $result->fetch_assoc()) { $totalCost+=$row["price"]; ---------------------------- why $totalCost =0?what happen?
  9. Error message: Query failed:You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 -------------------------------------- Can any one able to edit it in correct form?(*I using PHP5) ---------------------------------------------- $query="select count(*) from cart where cookieId ='GetCartId()' and bookid = '$bookid'";
  10. cty

    fatal error

    Hi,since i m newbie in php.Can u make it more understand what should i do?And how i edit my code? TQ
  11. Anyone know where is my mistake? The error show when i click on "buy" in product.php. Please guide me. --------------------------------------------------------- Error shown: Fatal error: Call to a member function fetch_row() on a non-object in C:\test\kelly.php on line 14 ---------------------------------------------------------- //product.php <?php include("db.php"); $db=new mysqli('localhost','root','','test'); $db->select_db('test'); $query="select * from book order by title asc"; $result = $db->query($query); ?> <?php while($row =$result->fetch_assoc()) { ?> <table border=1 width=80% bgcolor="pink"> <tr> <td width=20%> <font face="verdana" size="2" color="black" > ISBN : </font> </td> <td > <font face="verdana" size="2" color="black"> <?php echo $row["isbn"]; ?> </font> </td> </tr> <tr> <td width=20%> <font face="verdana" size="2" color="black"> TITLE: </font> </td> <td > <font face="verdana" size="2" color="black"> <?php echo $row["title"]; ?> </font> </td> </tr> <tr> <td width=20%> <font face="verdana" size="2" color="black"> Author : </font> </td> <td > <font face="verdana" size="2" color="black"> <?php echo $row["author"]; ?> </font> </td> </tr> <tr> <td width=20%> <font face="verdana" size="2" color="black"> Description : </font> </td> <td > <font face="verdana" size="2" color="black"> <?php echo $row["description"]; ?> </font> </td> </tr> <tr> <td width=20%> <font face="verdana" size="2" color="black"> Condition : </font> </td> <td > <font face="verdana" size="2" color="black"> <?php echo $row["condition"]; ?> </font> </td> </tr> <tr> <td width=20%> <font face="verdana" size="2" color="black"> Price(RM) : </font> </td> <td > <font face="verdana" size="2" color="black"> <?php echo $row["price"]; ?> </font> </td> </tr> <td > <font face="verdana" size="2" color="black"> <a href="cart.php?action=add_item&id=<?php echo $row["bookid"];?>">Buy</a> </font> </td> </tr> <br /> </table> <?php }?> <tr> <td > <hr size="2" color="red" NOSHADE> </td> </tr> <tr> <td > <font face="verdana" size="5" color="black"> <a href="cart.php"> View Your Shopping Cart &gt;&gt;</a> </font> </td> </tr> </table> </body> </html> ------------------------------------------------ //kelly.php <?php function AddItem($bookid){ $db=new mysqli('localhost','root','','test'); $db->select_db('test'); $query="select count(*) from cart where cookieId = '" . GetCartId() . "' and bookid = $bookid"; $result=$db->query($query); $row =$result->fetch_row(); $numRows = $row[0]; if($numRows == 0) { // This item doesn't exist in the users cart, // we will add it with an insert query $query="insert into cart(cookieId, bookid) values('" . GetCartId() . "', $bookid)"; $result=$db->query($query); } else { echo "The book already in your shopping cart."; // This item already exists in the users cart, } } function RemoveItem($bookid){ $db=new mysqli('localhost','root','','test'); $db->select_db('test'); $query="delete from cart where cookieId = '" . GetCartId() . "' and bookid = $bookid"; $result=$db->query($query); } function ShowCart(){ $db=new mysqli('localhost','root','','test'); $db->select_db('test'); $query="select * from cart inner join items on cart.bookid = book.bookid where cart.cookieId = '" . GetCartId() . "' order by book.title asc"; $result=$db->query($query); $totalCost=0; while($row = $result->fetch_assoc()) { // Increment the total cost of all items $totalCost+=$row["price"]; ?> <td width="55%" height="25"> <font face="verdana" size="1" color="black"> <?php echo $row["title"]; ?> </font> </td> <td width="20%" height="25"> <font face="verdana" size="1" color="black"> $<?php echo number_format($row["price"], 2, ".", ","); ?> </font> </td> <td width="10%" height="25"> <font face="verdana" size="1" color="black"> <a href="cart.php?action=remove_item&id=<?php echo $row["bookid"]; ?>">Remove</a> </font> </td> </tr> <br /> <?php } ?> <tr> <td width="100%" colspan="4"> <hr size="1" color="red" NOSHADE> </td> </tr> <tr> <td width="70%" colspan="2"> <font face="verdana" size="1" color="black"> <a href="products.php">&lt;&lt; Keep Shopping</a> </font> </td> <td width="30%" colspan="2"> <font face="verdana" size="2" color="black"> <b>Total: $<?php echo number_format($totalCost, 2); ?></b> </font> </td> </tr> <?php } ?> --------------------------------------------------- //cart.php <?php include("kelly.php"); include("db.php"); ?> <?php switch($_GET["action"]) { case "add_item": { AddItem($_GET["bookid"]); ShowCart(); break; } case "remove_item": { RemoveItem($_GET["bookid"]); ShowCart(); break; } default: { ShowCart(); } } ?> --------------------------------------------------- //db.php <?php function GetCartId() { // This function will generate an encrypted string and // will set it as a cookie using set_cookie. This will // also be used as the cookieId field in the cart table if(isset($_COOKIE["cartId"])) { return $_COOKIE["cartId"]; } else { // There is no cookie set. We will set the cookie // and return the value of the users session ID session_start(); setcookie("cartId", session_id(), time() + ((3600 * 24) * 30)); return session_id(); } } ?> -----------------------------------------------//end
  12. my problem is :whenever i log in ,it always shown 'You are not log in'. Never show "You are logged in as :xxx" For example:i do a testing,i input username:abc and password:1234 in "user" table. Next,i try to log in using abc and 1234.But,still shown 'You are not log in' can anyone tell me which part have bugs?or how i edit the code? I already use a phpeditor to check bugs,but no warning shown. Hope u able to help me. TQ ------------------------------------------------------------------------------ //login.html <html> <head> <title>Login here</title> </head> <body> <form method="POST" action="login.php"> Username <input type="text" name="username" size="20"></p> Password <p><input type="text" name="password" size="20"></p> <input type="submit" value="Submit" name="B1"> <input type="reset" value="Reset" name="B2"></p> </form> </body> </html> ---------------------------------------------------------------------- //login.php <?php session_start(); if(isset($_POST['username'])&&isset($_POST['password'])) { $username=$_POST['username']; $password=$_POST['password']; $db=new mysqli('localhost','root','','kelly'); if(mysqli_connect_errno()){ echo 'Connection to database failed:'.mysqli_connect_error(); exit(); } $query='select* from user ' ."where username='$username'" ."and password=sha1('$password')"; $result=$db->query($query); if($result->num_rows >0) { $_SESSION['valid_user']=$username; } $db->close(); } ?> <html> <body> <h1>Home Page</h1> <?php if(isset($_SESSION['valid_user'])) { echo'You are logged in as :'.$_SESSION['valid_user'].'<br />'; } else { echo'You are not log in'; } ?> -----------------------------------------------------------------------//end
  13. 1)Error display in cart.php page: PHP Notice: Undefined offset: 0 in C:\test\kelly.php on line 16 PHP Notice: Undefined variable: totalCost in C:\test\kelly.php on line 61 2)Error show when i try to remove item form cart: PHP Notice: Undefined variable: db in C:\test\kelly.php on line 43 PHP Fatal error: Call to a member function query() on a non-object in C:\test\kelly.php on line 43 -------------------------------------------------------- //This is  "db.php" <?php function GetCartId() { // This function will generate an encrypted string and // will set it as a cookie using set_cookie. This will // also be used as the cookieId field in the cart table if(isset($_COOKIE["cartId"])) { return $_COOKIE["cartId"]; } else { // There is no cookie set. We will set the cookie // and return the value of the users session ID session_start(); setcookie("cartId", session_id(), time() + ((3600 * 24) * 30)); return session_id(); } } ?> ------------------------------------------------------------------- //This is "product.php" <?php include("db.php"); $db=new mysqli('localhost','root','','test'); $db->select_db('test'); $query="select * from items order by itemName asc"; $result = $db->query($query); ?> <?php while($row =$result->fetch_assoc()) { ?> <table border=2> <tr> <td width="30%" height="25"> <font face="verdana" size="2" color="black"> <?php echo $row["itemName"]; ?> </font> </td> <td width="10%" height="25"> <font face="verdana" size="2" color="black"> <?php echo $row["itemPrice"]; ?> </font> </td> <td width="50%" height="25"> <font face="verdana" size="1" color="black"> <?php echo $row["itemDesc"]; ?> </font> </td> <td width="10%" height="25"> <font face="verdana" size="2" color="black"> <a href="cart.php?action=add_item&id=<?php echo $row["itemId"]; ?>&qty=1">Add Item</a> </font> </td> </tr> <br /> <?php }?> <tr> <td width="100%" colspan="4"> <hr size="1" color="red" NOSHADE> </td> </tr> <tr> <td width="100%" colspan="4"> <font face="verdana" size="1" color="black"> <a href="cart.php"> View Your Shopping Cart &gt;&gt;</a> </font> </td> </tr> </table> </body> </html> --------------------------------------------------------- //This is "cart.php" <?php include("kelly.php"); include("db.php"); ?> <?php switch($_GET["action"]) { case "add_item": { AddItem($_GET["id"], $_GET["qty"]); ShowCart(); break; } case "update_item": { UpdateItem($_GET["id"], $_GET["qty"]); ShowCart(); break; } case "remove_item": { RemoveItem($_GET["id"]); ShowCart(); break; } default: { ShowCart(); } } ?> ----------------------------------------------- //This is "kelly.php" <?php function AddItem($itemId, $qty){ $db=new mysqli('localhost','root','','test'); $db->select_db('test'); $query="select count(*) from cart where cookieId = '" . GetCartId() . "' and itemId = $itemId"; $result=$db->query($query); $row =$result->fetch_assoc(); $numRows = $row[0]; if($numRows == 0) { // This item doesn't exist in the users cart, // we will add it with an insert query $query="insert into cart(cookieId, itemId, qty) values('" . GetCartId() . "', $itemId, $qty)"; $result=$db->query($query); } else { // This item already exists in the users cart, // we will update it instead UpdateItem($itemId, $qty); } } function UpdateItem($itemId, $qty){ $query="update cart set qty = $qty where cookieId = '" . GetCartId() . "' and itemId = $itemId"; $result=$db->query($query); } function RemoveItem($itemId){ $query="delete from cart where cookieId = '" . GetCartId() . "' and itemId = $itemId"; $result=$db->query($query); } function ShowCart(){ $db=new mysqli('localhost','root','','test'); $db->select_db('test'); $query="select * from cart inner join items on cart.itemId = items.itemId where cart.cookieId = '" . GetCartId() . "' order by items.itemName asc"; $result=$db->query($query); while($row = $result->fetch_assoc()) { // Increment the total cost of all items $totalCost += ($row["qty"] * $row["itemPrice"]); ?> <td width="55%" height="25"> <font face="verdana" size="1" color="black"> <?php echo $row["itemName"]; ?> </font> </td> <td width="20%" height="25"> <font face="verdana" size="1" color="black"> $<?php echo number_format($row["itemPrice"], 2, ".", ","); ?> </font> </td> <td width="10%" height="25"> <font face="verdana" size="1" color="black"> <a href="cart.php?action=remove_item&id=<?php echo $row["itemId"]; ?>">Remove</a> </font> </td> </tr> <br /> <?php } ?> <tr> <td width="100%" colspan="4"> <hr size="1" color="red" NOSHADE> </td> </tr> <tr> <td width="70%" colspan="2"> <font face="verdana" size="1" color="black"> <a href="products.php">&lt;&lt; Keep Shopping</a> </font> </td> <td width="30%" colspan="2"> <font face="verdana" size="2" color="black"> <b>Total: $<?php echo number_format($totalCost, 2, ".", ","); ?></b> </font> </td> </tr> <?php } ?> --------------------------------------------------end//
  14. PHP Parse error: parse error, unexpected $end in C:\test\kelly.php on line 118 [code] <?php function AddItem($itemId, $qty){ $db=new mysqli('localhost','root','','test'); $db->select_db('test'); $query="select count(*) from cart where cookieId = '" . GetCartId() . "' and itemId = $itemId"; $result=$db->query($query); $row =$result->fetch_assoc(); $numRows = $row[0]; if($numRows == 0) { // This item doesn't exist in the users cart, // we will add it with an insert query $query="insert into cart(cookieId, itemId, qty) values('" . GetCartId() . "', $itemId, $qty)"; $result=$db->query($query); } else { // This item already exists in the users cart, // we will update it instead UpdateItem($itemId, $qty); } } function UpdateItem($itemId, $qty){ $query="update cart set qty = $qty where cookieId = '" . GetCartId() . "' and itemId = $itemId"; $result=$db->query($query); } function RemoveItem($itemId){ $query="delete from cart where cookieId = '" . GetCartId() . "' and itemId = $itemId"; $result=$db->query($query); } function ShowCart(){ $query="select * from cart inner join items on cart.itemId = items.itemId where cart.cookieId = '" . GetCartId() . "' order by items.itemName asc"; $result=$db->query($query); while($row = $result->fetch_assoc()) { // Increment the total cost of all items $totalCost += ($row["qty"] * $row["itemPrice"]); ?> <tr> <td width="15%" height="25"> <font face="verdana" size="1" color="black"> <select name="<?php echo $row["itemId"]; ?>" onChange="UpdateQty(this)"> <?php for($i = 1; $i <= 20; $i++) { echo "<option "; if($row["qty"] == $i) { echo " SELECTED "; } echo ">" . $i . "</option>"; } ?> </select> </font> </td> <td width="55%" height="25"> <font face="verdana" size="1" color="black"> <?php echo $row["itemName"]; ?> </font> </td> <td width="20%" height="25"> <font face="verdana" size="1" color="black"> $<?php echo number_format($row["itemPrice"], 2, ".", ","); ?> </font> </td> <td width="10%" height="25"> <font face="verdana" size="1" color="black"> <a href="cart.php?action=remove_item&id=<?php echo $row["itemId"]; ?>">Remove</a> </font> </td> </tr> <tr> <td width="100%" colspan="4"> <hr size="1" color="red" NOSHADE> </td> </tr> <tr> <td width="70%" colspan="2"> <font face="verdana" size="1" color="black"> <a href="products.php">&lt;&lt; Keep Shopping</a> </font> </td> <td width="30%" colspan="2"> <font face="verdana" size="2" color="black"> <b>Total: $<?php echo number_format($totalCost, 2, ".", ","); ?></b> </font> </td> </tr> [/code]
  15. Title:CAn anyone provide me a very simple code for shopping cart? Good day, I am newbie in PHP. I wish to learn to implement a shopping cart. Since i start doing my final year project with the title "buy and sell books". I have to learn how to code the shopping cart. I am using PHP5+MySQL4+IIS My idea is different user login will have different "account" that show what bookhe sell/buy. Can anyone do me a favour? Please provide me an easy understand coding(without"class") And is code with html/php5/mysql only. Or,you may tell me some useful website as well.TQ From , CTY Universtiy UTAR MALAYSIA
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.