Jump to content

Spring

Members
  • Posts

    224
  • Joined

  • Last visited

Posts posted by Spring

  1. my table has

     

    id, user_id, User_item_ids and User_item_shop_id

     

    Is that bad?

    Actually yes.

     

    And I'll try what you've suggested.

    I hope you're referring to the normalization. Besides, the LIKE %33% isn't quite right.

     

    What do you suggest rather than LIKE %33%

  2. Yes, it is. It's not logical and that's why you're having a pain working with it.

     

    Table should be:

     

    user_id, User_item_id, User_item_shop_id

     

    With a unique key on user_id and User_item_id

     

     

    EDIT:

     

    I'd even take out User_item_shop_id and put it in another table with:

     

    item_id, shop_id

     

    Appreciate it! This isn't my table, I'm working with an old script so any advice helps!

  3. I really don't get what you're asking. Are you asking how to fetch user_items that have "33" somewhere in there? You'll have to use LIKE %33% but I recommend you normalize your data. There should be a table for each user and an item they have. They shouldn't all be stored in one table.

     

    my table has

     

    id, user_id, User_item_ids and User_item_shop_id

     

    Is that bad?

     

    And I'll try what you've suggested.

  4. So here's my problem I'm not sure how to approach this:

     

    I have a table with user_items which are stored together separated by commas.

    13,12,11,9,27,15,16,22,21,23,24,26,29,30,31,32,33

     

    Now, I have a script where the user is in a trade and I want to verify the item they are trying to trade, but is there an alternative other than grabbing all of that users' items and checking that one item with all of the records?

     

    I've tried using

    SELECT * FROM MYTABLE WHERE user_item_id IN(33)

    As an example to see if it will pull the rows with that ID.  It didn't seem to work, am I doing it wrong? if so, forgive me. Any suggestions/help? The main problem is I don't want to have to explode that data and use a foreach to check that one item against all of that users items, as they could have well over 500.

  5. Looks correct to me, you can try this if you want.

     

    $("input").live("click", function(){ $(this).addClass("focus");  });

     

    Also there could be another part of your Jquery incorrect that's breaking the script.

  6. I have no database interaction in my controller, that is the model I'm using.

     

    Then why does it extend the CI_Controller ?

     

    That's the fix that I made, but while I have you I do have another problem..

    This code is almost directly from the user_guide find on the website, but my CI doesn't recognize the library..Am I better off asking on the CI forums? Or do you think you can give it a go? The error is the same as above.

    $config['image_library'] = 'gd2';
    	$config['source_image'] = '/ci/images/port/threechan.png';
    	$config['create_thumb'] = TRUE;
    	$config['maintain_ratio'] = TRUE;
    	$config['width'] = 75;
    	$config['height'] = 50;
    
    	$this->load->library('image_lib', $config);
    
    	 echo $this->image_lib->resize();

     

    Jesus never, I'm just not going to program late night, thank you.

  7. intval

     

    You shouldn't loop queries though, unless you absolutely have to.

     

    Since you've stored the values in a comma separated list, rather than in their own rows, you will need to use two queries though. Check out the IN syntax

    http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_in

     

    Highly appreciate the MySQL IN syntax. I have never used it before. I'll try these out and update you accordingly.

  8. Well, In my DB i have user items as follows:

    13,12,11,9,27,15,16,22,21,23,24,26,29,30,31,32,33

     

    Each ID is a user item that has been imploded to be sent to the DB. Well, I', trying to take them out of the DB now, and I'm having a small problem turning them back into integers.  Here's what I've done.

     

    $items = explode(",", $row['user_item_id']);

    So I get:

      0 => string '13' (length=2)
      1 => string '12' (length=2)
      2 => string '11' (length=2)
      3 => string '9' (length=1)
      4 => string '27' (length=2)
      5 => string '15' (length=2)
      6 => string '16' (length=2)
      7 => string '22' (length=2)
      8 => string '21' (length=2)
      9 => string '23' (length=2)
      10 => string '24' (length=2)
      11 => string '26' (length=2)
      12 => string '29' (length=2)
      13 => string '30' (length=2)
      14 => string '31' (length=2)
      15 => string '32' (length=2)
      16 => string '33' (length=2)

     

    Then I do this:

    foreach($items as $item){
    				var_dump($item);
    				$sql = 'SELECT *
    				FROM `MYTABLE`
    				WHERE item_tab = '.$tab_id.'
    				AND item_id = '.$item.'
    				AND item_pose =0';
    			}

     

    and get this:

    string '13' (length=2)
    
    string '12' (length=2)
    
    string '11' (length=2)
    
    string '9' (length=1)
    
    string '27' (length=2)
    
    string '15' (length=2)
    
    string '16' (length=2)
    
    string '22' (length=2)
    
    string '21' (length=2)
    
    string '23' (length=2)
    
    string '24' (length=2)
    
    string '26' (length=2)
    
    string '29' (length=2)
    
    string '30' (length=2)
    
    string '31' (length=2)
    
    string '32' (length=2)
    
    string '33' (length=2)
    

     

    Now, this works how I want it to except, I want a integer value not a string. What would be the best way to approach this?

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