Jump to content

ragrim

Members
  • Posts

    45
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ragrim's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi, Im having a wierd issue when building a search form i can get results using "like" or greater then less then but when ever i try to search with = i get no results, wether its a date field or a text field i get nothing, i tested the query in navicat and it works fine. the $expiresquery is a variable from a combo box if the user wants to search for < , > , = or like all of them work except = $query = "SELECT userinfo.User_ID, userinfo.FirstName, userinfo.LastName, userinfo.Phone , userinfo.Mobile , userinfo.Email2 , userinfo.Email , userinfo.PostCode , userinfo.Suburb , userinfo.Address , userinfo.State , userinfo.DOB , userinfo.SecondCardName , userinfo.BusinessName , userinfo.Concession , userinfo.CreatedBy , userinfo.Proof , subscribernumbers.SubNumber , subtransactions.Expires , subtransactions.`SubType` , userinfo.Datecreated , userinfo.LastModified , subtransactions.RecieptNum , subtransactions.TransDate , subtransactions.PaymentType , subtransactions.NewSubTrans FROM userinfo Inner Join subscribernumbers ON userinfo.User_ID = subscribernumbers.FKUserID INNER JOIN (SELECT FKSubNum, MAX(NewSubTrans) AS max_trans FROM subtransactions GROUP BY FKSubNum ) AS m ON m.FKSubNum = subscribernumbers.SubNumber Inner Join subtransactions ON subscribernumbers.SubNumber = subtransactions.FKSubNum AND subtransactions.NewSubTrans = m.max_trans"; $whereClause = " WHERE 1 = 1 "; if($fname != 'ANY' && !empty($fname)) { $whereClause .= " AND FirstName " . $fnamequery . "'%$fname%' "; } if($lname != 'ANY' && !empty($lname)) { $whereClause .= " AND LastName LIKE '%$lname%' "; } if($address != 'ANY' && !empty($address)) { $whereClause .= " AND Address LIKE '%$address%' "; } if($suburb != 'ANY' && !empty($suburb)) { $whereClause .= " AND Suburb LIKE '%$suburb%' "; } if($po != 'ANY' && !empty($po)) { $whereClause .= " AND PostCode LIKE '%$po%' "; } if($businessname != 'ANY' && !empty($businessname)) { $whereClause .= " AND BusinessName LIKE '%$businessname%' "; } if($expires != 'ANY' && !empty($expires)) { $whereClause .= " AND Expires " . $expiresquery . "'%$expires%' "; } when i echo out the query i get SELECT userinfo.User_ID, userinfo.FirstName, userinfo.LastName, userinfo.Phone , userinfo.Mobile , userinfo.Email2 , userinfo.Email , userinfo.PostCode , userinfo.Suburb , userinfo.Address , userinfo.State , userinfo.DOB , userinfo.SecondCardName , userinfo.BusinessName , userinfo.Concession , userinfo.CreatedBy , userinfo.Proof , subscribernumbers.SubNumber , subtransactions.Expires , subtransactions.`SubType` , userinfo.Datecreated , userinfo.LastModified , subtransactions.RecieptNum , subtransactions.TransDate , subtransactions.PaymentType , subtransactions.NewSubTrans FROM userinfo Inner Join subscribernumbers ON userinfo.User_ID = subscribernumbers.FKUserID INNER JOIN (SELECT FKSubNum, MAX(NewSubTrans) AS max_trans FROM subtransactions GROUP BY FKSubNum ) AS m ON m.FKSubNum = subscribernumbers.SubNumber Inner Join subtransactions ON subscribernumbers.SubNumber = subtransactions.FKSubNum AND subtransactions.NewSubTrans = m.max_trans WHERE 1 = 1 AND Expires ='%2022-06-28%'
  2. Hi, I have a website that has cart and checkout and im rying to submit a form after i have a javascript popup asking to confirm order submit and clear cart, my form has 3 differant buttons and based on which button the form is submitted with the page does differant things, i just cant seem to get it to work as javascript tends to just "submit" the form not submit it by the id/name of the button i tried to submit with. heres my code. this is the form, ive cut alot of code out as its about 100 lines long <form id="order" method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> <a href="#" class="linkButton" onclick="clear_confirm()">Empty Cart</a> <input type="submit" class="formButton" name="update" value="Update Cart" /> <input type="submit" onclick="order_confirm()" value="Place Order" name="place_order" class="formButton" /> </form> heres the javascript function clear_confirm() { var r=confirm("Are you sure you want to empty the cart?") if (r==true) { window.location="index.php?location=cart.php&action=empty"; } else { } } function order_confirm() { var r=confirm("Are you sure you want to place the order") if (r==true) { document.forms["order"].submit(); } else { } } the clear and update work fine because the clear redirects to a new page, and the update self submits without going via javascript, but when i click on order confirm the java popup appears for confirmation but the page doesnt get submitted, when the page is submitted via order_confirm it should pick up this part if(isset($_POST['place_order'])) { echo "place order"; } am i missing something in the javascript to make it submit the form? thanks in advance
  3. Hi, Im pretty much self taught when it comes to php, never read any books just picked things up as i go, and im looking for some advice on how i build my pages as i believe im not approaching it correctly. Basically i build an index.php, this contains my header, footer, and any menus i may have, then for my content pages, in this case products, contact, about us i use use an include so these content pages just have content. Now by doing this my address bar looks like this index.php?location=contact.php for the sake of google and search results and so on, am i limiting my ability to be found by not using a differant file for each page? should i include a header, footer, menu etc within my content pages rather than the other way around? Thanks in advance for any advice.
  4. Hi Guys, Ive launched my first real website, ive done a few small things in the past but this is the largest project i have done, with product categories and customer logins etc. Any feedback about the performance and features would be appreciated. http://byronhealthfoods.com.au/ Cheers
  5. i made a change to my code and have not recieved any errors as yet, but its hard to tell if i fixed it as this error is random and doesnt happen all the time. i changed it to if(isset($_SESSION['cart'][$pid])) { $_SESSION['cart'][$pid]=$_SESSION['cart'][$pid]+$q; } else { $_SESSION['cart'][$pid]=$q; } I was reading in the php manual that using isset may not be the right way to go about this but its the only way i could avoid the error as any other way seems to produce random errors. Any help would be appreciated.
  6. Hi, Im encountering this error when i add items to my cart, im using sessions to store my cart items in an array. this error only happens the first time i add something, then if i go clear my session it works and no errors. Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /home/byronhea/public_html/oos/mini-cart.php on line 18 Here is the line its refering to if(array_key_exists($pid, $_SESSION['cart'])) and here is the block of code it belongs to if(!isset($_SESSION)) { session_start('cart'); } // Process actions $pid = $_POST['prodid']; $q = $_POST['qty']; if(array_key_exists($pid, $_SESSION['cart'])) { $_SESSION['cart'][$pid]=$_SESSION['cart'][$pid]+$q; } ELSE { $_SESSION['cart'][$pid]=$q; } Any help would be appreciated.
  7. Hi, i have a script to import a csv into a database but some of my product descriptions have ' in the names, this causes mysql to error, how can i get around this? here is my code. if(isset($_POST['submit'])) { $i=0; $fname = $_FILES['sel_file']['name']; $chk_ext = explode(".",$fname); if(strtolower($chk_ext[1]) == "csv") { mysql_query("truncate table products") ; $filename = $_FILES['sel_file']['tmp_name']; $handle = fopen($filename, "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { if($i > 0) { $sql = "INSERT into products(prod_id,prod_name,prod_description,prod_cat,prod_sub_cat,tax,prod_price,active) values('$data[0]','$data[1]','$data[9]','$data[14]','$data[15]','$data[19]','$data[35]','$data[65]')"; mysql_query($sql) or die(mysql_error()); } $i++; } fclose($handle); echo "Successfully Imported<br>"; } else { echo "Invalid File"; } }
  8. update, after i posted i had a lightbulb moment and figured out how i can do the update, but now my problem is how can i pass the values of the new quantities to the script, for example here is my form and how i display the quantities. <td><input type='text' value='" . $value . "'</td> Now after this has processed and i have say 3 items in cart it looks like this in html <td><input type='text' value='1'</td> <td><input type='text' value='2'</td> <td><input type='text' value='3'</td> because each text field doesnt have a unique name how can i pass each of the values to my script to check if the qty has changed and if needed update the quantities. Cheers.
  9. Hi, i have had some help from these forums building a shopping cart system and i can add items to cart, empty cart but i need some help on how to update quantities. Here is the code i use to add items $pid = $_POST['prodid']; $q = $_POST['qty']; if(array_key_exists($pid, $_SESSION['cart'])) { $_SESSION['cart'][$pid]=$_SESSION['cart'][$pid]+$q; } ELSE { $_SESSION['cart'][$pid]=$q; } Im displaying my items in a table with a text field for quantities which can be changed then click update. i see there is 2 things i need to do, first is to somehow create a loop for all the items in my table, i have no clue where to start on that, and then in that loop i have my update command. im assuming the code to update would be something like $_SESSION['cart'][$pid]=$_SESSION['cart'][$pid][$qty] where $qty is the value of the text box in my table. Any help would be appreciated.
  10. Thank you for the quick response, that works perfect!
  11. Hi, I have 2 sessions in use, 1 for my login/authhentication and 1 for my cart, when an order is placed i want to empty the cart session, ive done some reading and session_destroy() seems to be the way im suppose to do this but when i do it destroys my login session so i have to relogin, is there any other way to just empty a session? i have tried session_destroy('cart') but doesnt seem to do anything. Cheers.
  12. Im not actually sure, im just using a session_start() at the top of my index page.
  13. Hi, Im building a cart system and i have sessions for my cart and for my login, i find as soon as i login im getting a blank line added to my cart so im assuming its conflicting with my login session. This is my login session $_SESSION['SESS_MEMBER_ID'] And my cart session is $_SESSION['cart'] The code im using to display my cart is $cart = $_SESSION['cart']; foreach( $cart as $key => $value){ echo "<td>" . $key . "</td><td><input type='text' value='" . $value . "'</td><td>Delete</td></tr>"; } What am i doing wrong here? any help would be appreciated.
  14. Hi, Im looking at building an online ordering system for a friends business but i dont want to reinvent the wheel, im wondering if anyone can recomend some free or cheap php scripts or applications for online ordering, i dont need payment options because all orders are done by accounts. all i need is something simple that has a cart, login system and order history. ive looked at zen cart and similar things but its more than i need, i want something i can just include into a webpage and use my theme without rebuilding it. Thanks.
  15. Thanks for the reply i managed to figure it out from a few tutorials i found, all is going well. Now i need to figure out how i can update and delete items from the session but ill have a crack at doing it myself before i ask for help. Thanks again.
×
×
  • 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.