Spring
-
Posts
224 -
Joined
-
Last visited
Posts posted by Spring
-
-
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%
-
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!
-
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.
-
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.
-
DOH! I found out the small mistake I made, sorry for wasting anyone's time.
-
-
function getCategoryName($cRow[0])
you don't call a function like that.
-
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.
-
You'd grab the user data from and unique ID and output that data on a page depending on the ID. There's no reason to actually create separate pages for each user.
-
Post the code if you want help.
-
When I use:
$sql = $this->db->prepare($sql_quest);
$sql->execute();
I get:
Fatal error: Call to a member function execute() on a non-object
Mind posting the whole code?
-
overflow: auto;
Maybe?
-
Any errors?
error_reporting(E_ALL); ini_set('display_errors', '1');
Maybe it's your permissions?
-
Ok.
$target = AVATAR_UPLOADPATH;
What is AVATAR_UPLOADPATH; set to then?
Ah I see it..
So..where is this file located? Is it in the root directory?
-
What's the problem though? What error are you getting with yours?
-
Did 'ya set up the DB connect correctly?
Where is $dbc defined?
-
$sql_quest = 'SELECT id, username FROM user ORDER BY id ASC LIMIT '. $my_int_value . ',' . $my_int_value + 30';
How's this?
Are you getting an error? Can 'ya post it?
-
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.
-
I got it working correctly now! For someone reason, the array didn't have the right keys..anyway,
$sql = 'select * from MYTABLE where item_id IN ('.$items.') AND item_tab = "'.$tab_id.'" AND `item_pose` = 0';
Worked fine!
-
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.
-
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?
-
I love the design.
-
Well, I'm officially confused.
Going to hand this over to someone else.
-
It's blank...odd.
I have this in there too:
ini_set("display_errors",1);
And nothing displays. Usually that will do it. 500 server error? This is on FF, BTW.
The entire page is blank?
Advice
in PHP Coding Help
Posted
I have done so.