Jump to content

ragrim

Members
  • Posts

    45
  • Joined

  • Last visited

    Never

Posts posted by ragrim

  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. 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.

  5. 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.

  6. 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";
    
         }    
    }

  7. 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.

  8. 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.

  9. 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.

  10. 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.

  11. 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.

  12. Thanks for that example it worked a charm, but im having problems trying to get the details out of it.

     

    ive added this code

     

    $cart = $_SESSION['cart'];
    foreach ($cart as $id)
    {
    echo $id . "<br>";	
    }

     

    This echos out the quantities for each of the items but i cant seem to be able to get the pid out, im assuming its because the pid has been saved as the array id? so question is how can i get that out in a way where i can query my DB for each of the PID's

     

    cheers

  13. Hi,

     

    Im trying to learn how to build a shopping cart system, im have a few problems and im not sure where im going wrong, it looks as though im getting an item into the session, but it looks like when i add another it over writing the first one, and im having trouble trying to echo it out.

     

    Here is what i have atm

     

    session_start();
    include('functions.php');
    
    $pid = $_GET['product'];
    $q = $_GET['qty'];
    
    if($_GET['function']=="add")
    {
    echo "add " . $_GET['product'];
    
    	$_SESSION['cart']=array();
    	$_SESSION['cart']['productid']=$pid;
    	$_SESSION['cart']['qty']=$q;
    
    
    }
    
    print_r($_SESSION['cart']);
    echo showCart();

     

    Am i way off on my code? regardless of how many things i try to add to session, all i can print out is the last one i entered.

     

    Cheers

  14. That helps alot in understanding how to build arrays, but i have just realised this is alot more complicated than i first thought, at the bottom of the php page was more code which i now see is the parts that builds the results, since my php skills are not that good im not sure how to use the code you provided.

     

    Heres the full code of the php

     

    <?php
    
    include('include/dbconnect.php');
    
    
    $result = mysql_query("SELECT * FROM clients");
    $aUsers = mysql_fetch_array($result);
    
    
    $input = strtolower( $_GET['input'] );
    $len = strlen($input);
    
    
    $aResults = array();
    
    if ($len)
    {
    	for ($i=0;$i<count($aUsers);$i++)
    	{
    		// had to use utf_decode, here
    		// not necessary if the results are coming from mysql
    		//
    		if (strtolower(substr(utf8_decode($aUsers[$i]),0,$len)) == $input)
    			$aResults[] = array( "id"=>($i+1) ,"value"=>htmlspecialchars($aUsers[$i]), "info"=>htmlspecialchars($aInfo[$i]) );
    
    		//if (stripos(utf8_decode($aUsers[$i]), $input) !== false)
    		//	$aResults[] = array( "id"=>($i+1) ,"value"=>htmlspecialchars($aUsers[$i]), "info"=>htmlspecialchars($aInfo[$i]) );
    	}
    }
    
    header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
    header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
    header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header ("Pragma: no-cache"); // HTTP/1.0
    
    
    
    if (isset($_REQUEST['json']))
    {
    	header("Content-Type: application/json");
    
    	echo "{\"results\": [";
    	$arr = array();
    	for ($i=0;$i<count($aResults);$i++)
    	{
    		$arr[] = "{\"id\": \"".$aResults[$i]['id']."\", \"value\": \"".$aResults[$i]['value']."\", \"info\": \"\"}";
    	}
    	echo implode(", ", $arr);
    	echo "]}";
    }
    else
    {
    	header("Content-Type: text/xml");
    
    	echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?><results>";
    	for ($i=0;$i<count($aResults);$i++)
    	{
    		echo "<rs id=\"".$aResults[$i]['id']."\" info=\"".$aResults[$i]['info']."\">".$aResults[$i]['value']."</rs>";
    	}
    	echo "</results>";
    }
    ?>

     

    I think i might be better off building my own ajax autocomplete as this code is a bit too complicated for me.

  15. sorry for the poor explanation im not sure how to explain it, this is the first time ive tried to build something like this.

     

    Im using this http://www.brandspankingnew.net/specials/ajax_autosuggest/ajax_autosuggest_autocomplete.html

     

    Now it supplies me a test.php that has a hard coded array, im trying to replace that array with data from my mysql database. When someone starts tying i want the text box to display the FirstName and LastName of clients, and when they select one it inputs the Client_ID of that person into the hidden field.

     

    Using the code above it pulls the data like this

     

    $aUsers = array(
    "ben",
    "dover"
    )

     

    it automatically adds an id for each item in array

     

    what i would like to do is have it come accross as

     

    $aUsers = mysql_fetch_array (
    "1","ben","dover"
    "2","next","user"
    )

     

    and to use my primary id field which is client_id

     

  16. Hi,

     

    Im building a form that has an ajax autocomplete and im trying to get my info from mysql to load into the array, i have it working but it displays the first name and last name for each person as a seperate array item, for example i have "ben dover" it treats ben as 1 array item and dover as second array item.

     

    what i need is to add each person from clients field in my DB to display as LastName, FirstName and Client_ID needs to come accross into my hidden field.

     

    heres the php code

     

    $result = mysql_query("SELECT * FROM clients");
    
    $aUsers = mysql_fetch_array($result);

     

    How do i add the 3 fields im pulling from DB into that array?

  17. Hi,

     

    Im building a custom theme for wordpress and i need some help with a loop, its not wordpress specific code just a general if and loop. heres what i have.

     

    $pages = get_pages('parent=0&sort_column=menu_order');
    if ($pages) {
    $output='';
      foreach ($pages as $page) {
      if($page->post_status=='publish'){
      	$output.='<li class=top><a href="'.$page->guid.'" class=top_link><span>'.$page->post_title.'</span></a>';
    
    	$sub_pages = get_pages( 'child_of ='. $page->ID);
       if ($sub_pages){
      
        foreach ($sub_pages as $sub_page) {
    	  if($sub_page->post_status=='publish'&& $sub_page->post_parent== $page->ID)
    	  {			
    		  if($sub_page->guid==" ")
    		  {
    			  
    		  }
    		  else
    		  {
    			$output.='<ul class=sub>';
    			$output.='<li><a href="'.$sub_page->guid.'">'.$sub_page->post_title.'</a></li>';
    			$output.='</ul>';
    		  }
    	  }
    	}
    
      }}
        $output.='</li>';
      }
    }

     

    What im trying to do is only echo <ul class=sub> and the inside <li> if there is something in sub_page guid. I managed to build this code and it works, but i need to move the <ul></ul> outside of the loop so it doesnt repeat over and over again, but i also dont want it being echoed if sub_page->guid is empty

     

    sorry for my poor explanation im doing the best i can.

     

    Thanks in advance for any help

  18. thanks for the test, from what i can tell its only 1 computer that seems to display the problem.

     

    Im still learning PHP, CSS so i bodgy alot of things just to get them to work, w3c never likes my sites.

     

    Thanks again

  19. Hi,

     

    Im having a problem that i think is div related.. I have a div that holds a javascript image slider, and some wierd things are happening.

     

    In some browsers all my divs get squashed to the top of the page yet in others it works ok. on the browsers that it doesnt work on, if i highlight the address bar and hit enter, it reloads the page and displays properly, if i then hit F5 to refresh it gets all squashed to the top again.

     

    I was hoping someone could take a look at my site and see what the hell is going on

     

    http://www.chrisconnollyit.com/sfv

     

    Here is the browsers that work

     

    Firefox on MAC OSX works fine

    Safari on MAC OSX doesnt work

    Chrome on MAC OSX doesnt work

     

    Firefox on Windows XP doesnt work

    Internet explorer on windows XP works

     

    The problem seems to be something to do with this section

        <div class="imgholder1">
        <img src="images/home-image5.jpg" width="900" /> 
        <img src="images/home-image4.jpg" width="900" />
        </div>

     

    Any help would be appreciated

×
×
  • 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.