Jump to content

Help on PHP AND MYSQL!


Monkuar

Recommended Posts

here is my query that pull's up from my table "cashlogs"

 

$result = $db->query('SELECT * FROM cashlogs ORDER By time DESC LIMIT '.$start_from.', 25') or error('Unable to fetch log info', __FILE__, __LINE__, $db->error());
        

 

Here is a screenshot on what I pull :)

 

28u04xy.jpg

 

I would love it  so I can pull my field imgaward from the user's table and apply them to each from_name and to_name fields in my cashlogs table. :) Possible?

 

I am trying to act professional and nice as i can please help me on this what, thanks!

 

I am asking you for help because I don't want to use WHERE Statement. because then I Would have like 250 Querys.. lol

Link to comment
https://forums.phpfreaks.com/topic/166578-help-on-php-and-mysql/
Share on other sites

Certainly easy to do, but we don't know the structure of the table.  What you want to do is modify the query so that it performs and inner join between cashlogs and the user table.  Because you are needing to join to the cashlogs table twice, you'll need to use table aliases.  In this example, I'm going to assume that the user table primary key is 'name' (again you haven't provided that info) so this is just a guess. Modify the query as needed.

 

'SELECT cl.*, uf.imagaward, ut.imagaward FROM cashlogs cl, user ut, user uf WHERE ut.name = cl.to_name AND uf.name = cl.from_name ORDER By time DESC LIMIT '.$start_from.'

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.