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
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.'

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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