Jump to content

Youko

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Youko's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the quick reply! The problem is I don't know how to do so. Also, instead of just printing the aammount left, I'd want it to be inserted back to the money cell.
  2. Yes, I think there is no way of you cracking that.
  3. So, I don't really know how to achieve this with php, so any help would be much appriciated. I bet this is so simple of a solution, I'll look like an idiot. :-\ So. I have 2 MySQL tables. I wan't to take an value from a cell on table 1, substract that from a cell from table 2 so that the new value saves to the cell on table 2. Like: money - item_price = this much money Thank's in advance!
  4. Since I can't edit my previous post anymore, I'll make a new one. It seems that if I replace return with echo, I get the whole list, but it just bloats it randomly to the top of the page and not where it is supposed to be so return has to be used. I wonder why return doesn't show them all.
  5. Ok, now my code looks like this: global $post_info, $user; if(check_class($post_info['user_class'], TRUE) || check_class($user['user_class'], TRUE)) { $user_class = $post_info['user_class']; } $query = "SELECT userclass_img FROM e107_userclass_classes WHERE userclass_id IN($user_class)"; if ($result = mysql_query($query)) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { $return $row['userclass_img']; } } } It still only show's the output for the first number in the variable, not for all, since they are separated with coma. Or atleast I think that's the reason. Btw, Thorpe, you had an error in your syntax. Not: if ($result = mysql_query($result)) { But: if ($result = mysql_query($query)) { Edit: Fixed some things...
  6. My deepest apologies, I misread. Yay! It works! *hugs* Thanks so much! Sorry that I tried your patience... All is well now.... atleast for now. Edit: ACtually there is still one issue, but we are getting there! It only checks the first number of the $usrclass and outputs the data acording to that, but id wan't it to go thru all the numbers in the variable. Is that possible? I mean that if a user has a userclass 1,2 only the picture from the userclass_img for class 1 gets output.
  7. I know, but since the variable has a value value like 2,3,,3 so it can't match it to the userclass_id I want the script to separate every number to individual variables Oviously it won't find a id 2,4,6 from the userclass_id columm, since they are only single number's there Every number that the variable has reperesents one userclass so if the user has more than one, they become separated with coma.
  8. Ok I'll try. I'l give a bigger picture, which most information ain't really relevant to the script itself, but to get a bigger picture. I have a CMS system and every user have their own user classes (Admins, MOds, etc) Theese userclasses have an unique id number from 1 to upwards. Now, the system is designed so that it stores all the userclass' the user has in the users table with teh format of, ex 2,5,3,6 Then the userclasses themselves are separated in another table as userclass_id userclass_img | userclass_name -------------------------------------------------------------------- 1 | http://blah.com/pic.jpg | Admin 2 | http://blah.com/pic.jpg | Moderator 3 | http://blah.com/pic.jpg | Whatever Ok. So, I have gotten the user's (that has posted something) userclasses to a variable, but since they are in a format with all the classes in the same columm separated with , so I can't compare that value in the variable with userclass_id's Now what I want to do is get every single number separated from, let's say 2,5,3 (the data in variable) to new variables or find an alternative way to do this. The goal I'm aiming to is that for every single userclass_id the userclass is formed of, the id's userclass_img columm get's shown on the site (return $blahblah). I hope that helped to understand better what I'm doing. Otherwise you need to ask some specific questions, since I don't know if I can explain this better.
  9. Thanks for the correction. (Altho that part of the code worked just fine... odd..) Edit: Actually that gives me a parse error, so that change does nothing good. Edit2: Oh nvm, fixed it. But still I need help with the aforementioned issue. I know now way on how to do that and it might even be impossible. If only the system I am working on wasn't designed like this...
  10. Ok, I'll post the code: // ignore these global $post_info, $user; // this is where i check the users class and this part of the code works, since // I can output the results with "return $user_class" if(check_class($post_info['user_class'], TRUE) || check_class($user['user_class'], TRUE)) { $user_class = "$post_info[user_class]"; } $query="SELECT * FROM e107_userclass_classes WHERE userclass_id=$user_class"; $res=mysql_query($query) or die(mysql_error()."<br />".$query); $row=mysql_fetch_array($res); return $row['userclass_img']; return $user_class; --------------- The solution you offered wouldn't work, since the variable is not constant. I'd want the script to check, let's say a value of 1,8,3 then perhaps store all those numbers to variables or some other way. So, that it checks if all those numbers (separetly) are found in the id columm and then outputs the next column from every id the numbers match to.
  11. Oh you'r reply was fast, thank you. I just happened to edit my previous post at the same time, hehe. If you would be kind enough to look at my previous post for new details. Edit: Indeed that was the issues. It doesn't understand the value the variable has. MySQL error follows. Thanks for the help with the error checking. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '3,5,6,7' at line 1 SELECT * FROM e107_userclass_classes WHERE userclass_id=2,3,5,6,7
  12. Edit: Oh now I know what's going on! The variable can have values in theese forms. Single number or multiple numbers separated by a , Now, ho do I get php to recognize all the numbers there? (this might get messy)
  13. First of, sorry that I keep pestering you guys. Ok, so I'm in a dead end once again. The solution is propably so simple, that I will be hitting my head to the mousepad afterwards, haha. Ok, so here it goes. I have a value set to a variable in php, so how can I make it check a table in a MySQL table from, let's say columm ID that if it finds that some value in the colum ID matches the value set to the variable, it outputs the data entered to the next colum from the same row it found the id from? The table in question is formed like this: id img_source ----------------------------------- 1 | http://site.com/blah1.jpg 2 | http://site.com/blah2.jpg 3 | http://site.com/blah3.jpg 4 | http://site.com/blah4.jpg So if the variable has a value of 3, it checks the database table if it has such a value in the id columm and then outputs the image link next to it. Thanks again!
  14. Sorry, I'm pretty new at this. If you could go into a greater detail on how doing that, please.
×
×
  • 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.