![]() |
PHP / MySQL Help!
ok just a few questions, unfortunately my coder is a fatass lazy piece of shit so i'm attempting this, if you can prove helpful i'll use you on the project.. its just a big move to remove the current programmer cause this is such a big ass project... anyhow...
This is a table that I'm currently working with. http://www.bodygain.com/gfypics/table.gif What I want to do is print out, "You have performed X amount of Exercises"... the initial coding i assume would go like this: $query = "SELECT abrv FROM bgusers WHERE uid=$uid"; $result = mysql_query($query); then how do you take the $result and exclude the duplicates then find out how many individual exercises there are after duplicates have been removed? i assume there is some kind of duplicate removing function in php... I assume this isn't too difficult for most coders out there... thx ;) |
I'm a coder and i'm 2 lazy to read the post!
So i'll give her a bump, it looks eazy |
Change your query...
$query = "SELECT abrv, count(*) AS total FROM bgusers WHERE uid=$uid" GROUP BY abrv; $result = mysql_query($query); Now when you mysql_fetch_array() or whatever your $result, you'll get a $result["abrv"] and a $result["total"] for each excercise. Cheers :glugglug |
its faster if you just do it with the mysql using the distinct keyword
$query = "SELECT DISTINCT abrv, count(*) AS total FROM bgusers WHERE uid=$uid" GROUP BY abrv; |
Quote:
|
lol I pasted from the wrong post but I guess it still works, however that " at the end of the select line should be moved to the end of course...
|
Is it just me or is that table really poorly designed?
|
Quote:
|
PHP Code:
|
Quote:
|
thx for the help.. but im still having fucking problems...
$query = "SELECT DISTINCT abrv FROM bgexercises WHERE uid=$_SESSION[userid]"; $resultss3 = mysql_query($query); $shit = mysql_num_rows($resultss3); print "$shit"; and its not printing dick. i didn't use all of your guys's coding cause i tried it and it didn't work.. all i'm trying to do is get how many different exercises there are n' thats it... god damn i hate this shit :winkwink: |
ooops! i was using "uid" instead of "userid". ;) it works now....
|
okay.. heres the next one, its a lot more complex... i want to do something like this:
"You have GAINED STRENGTH on over 2 different exercises within the past MONTH " this focuses specifically on the "data" field. we figure out the strength increase by this formula (using the first row from the picture up top): (35 * 15 + 50 * 10 + 80 * 8) / 3 now what we'd have to do is somehow be able to group the strings according to ABRV, and compare "data" from 1 month ago of each exercise, to NOW... and determine if there has been a strength gain.. then print the results. LOL, sounds like a bunch of shit.. thought i'd post it anyhow... if someone can get it right i'll paypal $30 if that'll raise incentive. :) if you're interested & need more specifics.. just post. |
(35 * 15 + 50 * 10 + 80 * 8) / 3
thats a formula? |
Give me a bit more data on ICQ, and I'll write the code you need within the hour. 172884621
|
If you want, contact me, I could help out with MYSQL/PHP. I've done the NSCash & ReelProfits affiliate area add-ons!
jDoG |
Quote:
jDoG |
btw, it looks like PhpMyAdmin table when you get the result of a query!:glugglug
|
All times are GMT -7. The time now is 12:32 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123