Jump to content

simpso

Members
  • Posts

    10
  • Joined

  • Last visited

simpso's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi For whatever reason this dosent seem to be working. Basically im trying to pull the price of an item from the database based on the id number i give the sql. <?php $idno = "1"; $cost = 'select price from products where Id = "$idno"'; ?> Have i missed something?
  2. Is ajax difficult to add in, would i need to manipulate my code much to get it to work with?
  3. HI everyone i have been messing about with creating a sessions shopping cart using arrays all day and i finally have it working but wanted to see if anyone knew of a smarter way to do it, possibly without having to leave the page? Basically i have an add to cart button with the product id within the hyper link. When clicked this takes you to a page called addtocart.php using $GET i take the id and add to $_session which runs on this page. the html then redicrects you back page you were on. Any ideas? Thanks Page 1 code <a href="addtocart.php?id=<?PHP echo $row_ItemsList['ID']; ?>" >Add to cart</a> Page 2 code <?php $id = $_GET['id']; if(isset($_SESSION['cartid'])) { $entry = count($_SESSION['cartid']); $_SESSION['cartid'][$entry]['productid'] = $id; }else { $_SESSION['cartid'] = array(); $_SESSION['cartid'][0]['productid'] = $id; } ?>
  4. Will do but i have an if up on line 65 <?php if(isset($_COOKIE['CartID']))
  5. Ok i have placed the curly brackets inand attempted the backwards quotes but still getting an error It jumps between unexpected ; on line 69 and when i take the ; out parse t string error. Code: <div id = "Test"><?php do { ?> <a href="AddToCartTest.php?id=<?php echo $row_ItemsList['ID']; ?>"><?php echo $row_ItemsList['ID']; ?> <?php if(isset($_COOKIE['CartID'])) {$CartIDs= $_COOKIE['CartID']; mysql_query("INSERT INTO 'cart' ('User_ID') VALUES ('$CartID')");} else LINE69 {(setcookie('CartID', rand()) mysql_query("INSERT INTO cart (User_ID) VALUES ('$CartID')"); ?> </a> <p> <?php } while ($row_ItemsList = mysql_fetch_assoc($ItemsList)); echo $CartIDs; ?>
  6. The error i am getting is : Parse error: syntax error, unexpected T_ELSE in C:\xampp\htdocs\LaughingSeagullV2\AddToCartTest.php on line 68
  7. HI everyone I am currently attempting to input the below code which will work when a user clicks on a link, however i am getting a parse else error when i insert the Insert into line. Anyone got any ideas, im sure is something simple but im new to this. Thanks <?php do { ?> <a href="AddToCartTest.php?id=<?php echo $row_ItemsList['ID']; ?>"><?php echo $row_ItemsList['ID']; ?> <?php if(isset($_COOKIE['CartID'])) $CartID= $_COOKIE['CartID']; mysql_query("INSERT INTO 'cart' ('User_ID') VALUES ('$CartID')"); else setcookie('CartID',RAND()); mysql_query("INSERT INTO 'cart' ('User_ID') VALUES ('$CartID')"); ?> </a> <p>
  8. Ah it was nothing:) Is this the full text searching that mr marcus described or something else? If so how would i go about splitting the search term up?
  9. Here is a copy of the code i am using. the database structure is simply ID Title Keywords <?php $search = $_GET['search']; $maxRows_Recordset1 = 10; $pageNum_Recordset1 = 0; if (isset($_GET['pageNum_Recordset1'])) { $pageNum_Recordset1 = $_GET['pageNum_Recordset1']; } $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; mysql_select_db($database_Laughing_seagull, $Laughing_seagull); $query_Recordset1 = "SELECT products.Title FROM products WHERE products.keywords LIKE '%".$search."%' OR products.Title LIKE '%".$search."%'"; $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1); $Recordset1 = mysql_query($query_limit_Recordset1, $Laughing_seagull) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); if (isset($_GET['totalRows_Recordset1'])) { $totalRows_Recordset1 = $_GET['totalRows_Recordset1']; } else { $all_Recordset1 = mysql_query($query_Recordset1); $totalRows_Recordset1 = mysql_num_rows($all_Recordset1); } $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1; ?>
  10. Hi everyone Im pretty new to this so bear with me if i state the obvious or anything Im currently adding a search function to my website using mysql and php. First of all i actually have the search working using the like function and the % wildcards to bring back multiple results. For searching i am looking at two coloums in my database title and key words. The keywords are broken up by spaces. The issue im having is when i search if i search for example new york this will bring back all the entries with new your in them but if i type new york city i get none because none of my keywords say city. Same happens if the words are types out of sequence from the way they are in the database. Does anyone have any idea how i can build this so for example with the new york city one the database will still return any entries that has new york? Hope this makes sense and i hope you can help. Thanks.
×
×
  • 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.