-
Posts
24,565 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
How many times do we have to answer this question for you? http://forums.phpfreaks.com/topic/294604-sorting-multidimensional-array/?do=findComment&comment=1505682
-
SELECT gallery.gal_id , gname , img_id , img_name FROM gallery INNER JOIN images ON images.gal_id=gallery.gal_id ORDER BY gal_id DESC WHERE gallery.user_id = $whatever LIMIT $eu,$limit
-
DISTINCT is not a function - it applies to the whole row and not a single field. It is also redundant when using GROUP BY. If you don't know how the images relate to users, how the hell do you expect us to know when we don't even know what your data looks like?
-
Why the double sets of quotes?
-
How to create query in log in that compares the id using php ?
Barand replied to aixen083's topic in PHP Coding Help
I gave you the idea - you do a JOIN on org_id to get records with matching values in that column -
looks like a unix time value Try SELECT FROM_UNIXTIME(last_post) FROM topics
-
You do the check on line 4. Do the same on line 3.
-
This will calculate the averages SELECT div_name as division , '' as company , '' as team , '' as project , AVG(s.score) as av_score FROM division d LEFT JOIN work_division wd ON d.division_id = wd.division_id LEFT JOIN score s ON wd.work_id = s.work_id GROUP BY d.division_id UNION SELECT '' as division , c.co_name as company , '' as team , '' as project , AVG(s.score) as av_score FROM company c LEFT JOIN work_company wc ON c.company_id = wc.company_id LEFT JOIN score s ON wc.work_id = s.work_id GROUP BY c.company_id UNION SELECT '' as division , '' as company , t.team_name as team , '' as project , AVG(s.score) as av_score FROM team t LEFT JOIN work_team wt ON t.team_id = wt.team_id LEFT JOIN score s ON wt.work_id = s.work_id GROUP BY t.team_id UNION SELECT '' as division , '' as company , '' as team , p.proj_name as project , AVG(s.score) as av_score FROM project p LEFT JOIN work_project wp ON p.project_id = wp.project_id LEFT JOIN score s ON wp.work_id = s.work_id GROUP BY p.project_id; Results: +-----------+--------------+--------+-----------+----------+ | division | company | team | project | av_score | +-----------+--------------+--------+-----------+----------+ | Northeast | | | | | | Northwest | | | | 6.0000 | | Southeast | | | | 6.6667 | | Southwest | | | | | | | Ajax Stores | | | 9.0000 | | | Body Shop | | | 6.0000 | | | Culpepper | | | | | | Danish Bacon | | | 5.3333 | | | | Team 1 | | 6.6667 | | | | Team 2 | | 6.8000 | | | | Team 3 | | 6.0000 | | | | | Project A | 7.6000 | | | | | Project B | | | | | | Project C | 9.0000 | | | | | Project D | | +-----------+--------------+--------+-----------+----------+
-
$conn = new PDO("mysql:host=$servername;$db", $user_name, $password); $stmt = $db->prepare("INSERT INTO Products(NAME, DESCRIPTION, PRICE, IMAGE, TYPE, MADE, DISTRIBUTE) Your PDO object is $conn.
-
How to create query in log in that compares the id using php ?
Barand replied to aixen083's topic in PHP Coding Help
If you don't know code from data then you are beyond help. Bye. -
How to create query in log in that compares the id using php ?
Barand replied to aixen083's topic in PHP Coding Help
Not without seeing your data and how it is really set up -
How to create query in log in that compares the id using php ?
Barand replied to aixen083's topic in PHP Coding Help
That's what the JOIN on the org_id is for. Then you would only use that column in the query SELECT v.id_number , c.firstname , c.lastname , c.image FROM candidates c INNER JOIN voters v ON v.org_id = c.org_id WHERE id_number='$id_number' AND password='$password' AND status='Unvoted' -
How to create query in log in that compares the id using php ?
Barand replied to aixen083's topic in PHP Coding Help
What? Please tell tell that's a typing error. -
How to create query in log in that compares the id using php ?
Barand replied to aixen083's topic in PHP Coding Help
Which of those two fields should match the value in $id_number? (If the answer is both, why are you storing it twice?) -
How to create query in log in that compares the id using php ?
Barand replied to aixen083's topic in PHP Coding Help
Which of those two fields should match the value in $id_number? (If the answer is both, why are you storing it twice?) -
How to create query in log in that compares the id using php ?
Barand replied to aixen083's topic in PHP Coding Help
Which of your tables contains "id_number" column. You didn't mention that before (I assume that "password" and "status" are in the voters table) -
I confess I am not sure how your scoring is implemented and how it really fits into the model. Would the score be related to the work_xxxxxx tables? I agree with Psycho that those statements imply hierarchy
-
It sounds like the attached model would serve and would allow "work" definitions such as +-----------+-----------+--------------+--------+-----------+ | work_name | Division | Company | Team | Project | +-----------+-----------+--------------+--------+-----------+ | Work 1 | Southeast | | | | | Work 1 | Northwest | | | | | Work 1 | | | Team 3 | | | Work 1 | | | Team 2 | | | Work 1 | | | Team 1 | | +-----------+-----------+--------------+--------+-----------+ | Work 2 | Northeast | | | | | Work 2 | | Danish Bacon | | | | Work 2 | | Body Shop | | | | Work 2 | | | Team 3 | | | Work 2 | | | Team 2 | | +-----------+-----------+--------------+--------+-----------+ | Work 3 | | Ajax Stores | | | | Work 3 | | | | Project C | | Work 3 | | | | Project A | +-----------+-----------+--------------+--------+-----------+ All I have to do now is figure out how to get your averages from that structure
-
Perhaps this is an occasion for separate queries. How different are the tables?
-
$sql = "SELECT item_id , category , sub_category , sub_sub_category , name , price FROM items ORDER BY category, sub_category, sub_sub_category"; $res = $db->query($sql); $data = array(); while (list($id, $cat, $subcat, $subsubcat, $name, $price) = $res->fetch_row()) { $data [$cat][$subcat][$subsubcat][$id] = ['name'=>$name, 'price'=>$price]; }
-
The fields in each column should be of matching types too
-
If you do a union like that then select dummy fields in the table with less data SELECT a, b, c FROM tablea UNION SELECT x, y, NULL as c FROM tableb
-
This is the same problem you posted in your other thread. Apply the same technique I gave you there. http://forums.phpfreaks.com/topic/294644-how-to-create-query-in-log-in-that-compares-the-id-using-php/?do=findComment&comment=1505910 Or do you want us to write the code for you every time?
-
Don't try building the json string in the query. Store query results in the array structure you want then json_encode that.
-
As cyberRobot had already told him to check the file locations a couple of times before you chimed in then no biscuit this time