Jump to content

Terminaxx

Members
  • Content Count

    39
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Terminaxx

  • Rank
    Member

Profile Information

  • Gender
    Not Telling
  1. Wow. Thanks you two! Especially for not just giving me the answer but also for the good explanation!
  2. Edit: Sorry to make it sound stupid again, but how exactly can I echo the sum correctly now? I tried this: while($row = mysqli_fetch_object($res)) { $name = $row->receiver; $row = mysqli_fetch_assoc($res); $sum = $row['value_sum']; echo "<tr>"; echo "<td>".$name."</td>"; echo "<td>".number_format($sum, 0, ",", ".")." Money</td>"; } Sorry if it is really easy for you and it annoys you, but I still try to learn and understand. It shows some results, but they are way too low so they can't be correct.
  3. Hey, thanks for your help it sound really logical. I also would like to thank you for your third hint. Going to consider it when I code again! Thanks again. Edit: Got it!
  4. Sorry but I don't really get it. I tried this: $result = mysqli_query($con, "SELECT SUM(action) AS value_sum FROM transactions WHERE comment = 'tax' ORDER BY receiver"); Did you mean this? Or how exactly am I gonna do this? Sorry but im kinda new to this.
  5. Hey guys, I got a table where transactions are listed in, therefore we got once the "receiver", the "comment" and the "action" (amount) For exmaple User A - something - 50 User B - something - 50 User C - tax - 100 User D - tax - 100 User D - tax - 200 User F- tax - 200 I want to get the sum from every action with the comment "tax" listed by users So it should be like this: User C - tax - 100 User D - tax - 300 <-- 200 + 100 User F - tax - 200 How can I do this? Thanks for any help and I hope it is clear, what I am trying to do.
  6. Got it now. Thanks for the explanations and sorry for annoying you.
  7. It still isn't working. Not sure what I am doing wrong. Could you add the code up, as i should have put it in to check if I got it correctly? Would be awesome! I got the above part from my latest version, where I didnt want to have them seperated. I am kinda confused about all the code here...
  8. Thanks, I understood it now. But I gotta annoy you one last time: <?php $res = mysqli_query($con, "SELECT s.name , s.price , s.quantity , s.img , s.id , s.owner FROM shop s JOIN ( SELECT name , MIN(price) as price FROM shop GROUP BY name ) mins USING (name, price)"); $furnis = array(); $names = array(); while($row = mysqli_fetch_object($res)) { $id = $row->id; $img = $row->img; $owner = $row->number; $name = $row->name; $price = $row->price; $quantity = $row->quantity; if(!in_array($name, $names)) { $f = new furnipack(); $f->img = $img; $f->quantity = $quantity; $f->name = $name; $f->price = $price; $f->id = $id; array_push($furnis, $f); array_push($names, $name); } } } foreach ($furnis as $f) { echo "<h3>$f->name</h3>"; echo "<h5>".number_format($f->price, 0, ",", ".")."</h5>"; echo "$f->quantity x"; echo "<input name='quantity[$f->id]' type='number' value='1' min='1' max='$f->quantity'>"; echo "<button type='submit' name='buy' value='$f->id'>Buy</button>"; } } ?> I got the total code now something similar like this. I mean, I still gotta put the results in variables right? How else would i echo them What did I do wrong - is it because of the "if(!in_array($name, $names))" code? or did i mistake something once again with your code?
  9. Thanks for the answers but I kinda dont understand the code (im quite new to this and just try to learn) Like I do not understand what you mean by s.price etc. - what is the s for? Why select something from shop s? I understood it like this: $res = mysqli_query($con, "SELECT * FROM shop"); while($row1 = mysqli_fetch_object($res)) { $name1 = $row1->name; $price1 = $row1->price; $res2 = mysqli_query($con, "SELECT * FROM shop JOIN ( SELECT name, MIN(price) as price FROM shop GROUP BY name ) mins USING ($name1, $price1)"); while($row = mysqli_fetch_object($res2)) { $id = $row->id; $img = $row->img; $owner = $row->number; $name = $row->name; $price = $row->price; $quantity = $row->quantity; } But I am pretty sure I did it wrong. Excuse me for my stupid question - it might sound clear to someone who isnt new to this. Thanks in advance
  10. Hey guys, I got a table something like this: ID name price quantity 1 name1 40 5 2 name1 50 6 3 name2 30 7 4 name2 40 9 5 name1 60 11 I want to only get the objects with the lowest price from everywhere where the name is the same. So for example, if we look at the table above i want to get name1 (price 40 - quantity 5) and name2 (price 30 - quantity 7) How can I manage to do this? I tried this, but this could be somewhere belong wrong: $res = mysqli_query($con, "SELECT * FROM shop WHERE MIN(price / name)"); Thanks for any help
  11. Hey guys, first i want to apologize for my english and hope you still understand the meaning of it. I list items that you can buy and also choose the number, how many items you want to buy. Code: foreach ($furnis as $f) { echo "<h3>$f->name</h3>"; echo "<h5>".number_format($f->price, 0, ",", ".")." Taler</h5>"; echo "$f->quantity x"; if($money >= $f->price) { echo "<input name='quantity' type='number' min='1' max='$f->quantity'>"; echo "<button type='submit' name='buy' value='$f->id'>Buy</button>"; }else { echo "<button>Not enough money</button>"; } } To get the aricle, which is clicked is easily done with getting the ID: $id = input($_POST['buy']); Now my question is, how to get the quantity (inputfield) right? When I try the same: $quantity = input($_POST['quantity']); I do not get the quantity. Of course I get it, if only one article is displayed, but there are many more. So instead of getting the quantity of the article the person clicked on, i get a random quantity from an other article. How can I do it right? Thanks for any help
  12. The main problem is, how to get the timestamp out of the table, add 1 day and put it as a new column in. Therefore I got problems with representing the timestamp in the right order. I tried this: $highdate = mysqli_fetch_object(mysqli_query($con, "SELECT * FROM auctions ORDER BY yourdate DESC LIMIT 1"))->yourdate; $date = date_create('$highdate'); date_add($date, date_interval_create_from_date_string('2 days')); (tried it here with 2 days) but in the table i got it in this format: 0000-00-00 00:00:00
  13. Hey guys, first I want to apologize for my English and hope you still understand what i am trying to do. So i got a table with many timestamps in it - like this: 2017-11-04 00:00:00 I want to get the object with the highest timestamp (the farest day) and add exactly one day to it and add it to the table. Like if we say the above timestamp was the highest, the next one should be like this: 2017-11-05 00:00:00 How can i do this and add it to the table without any error? Thanks for any help
  14. Thank you once again for a good answer with an example given.
×
×
  • 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.