Jump to content


Photo

News Feed Design

social php sql

  • Please log in to reply
32 replies to this topic

#21 Jessica

Jessica

    This is not my name.

  • Gurus
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 25 February 2013 - 05:59 PM

Oh and by the way - I don't come here to "help" ungrateful whiny babies. So stop acting like a child and remember this is a FREE Help forum. (For the record, if someone paying me spoke to me in such an ungrateful manner I'd fire them, so I especially won't put up with it from someone I am donating my time to.) Grow up.
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#22 derekshull

derekshull

    Advanced Member

  • Members
  • PipPipPip
  • 107 posts

Posted 25 February 2013 - 06:53 PM

Ok so I think I get it, let me know if I'm wrong. The WHERE should have been the ON? And I needed to do a JOIN so I did a LEFT JOIN although I'm not sure of the differences. So I put in this:



$sql = "SELECT * FROM follow LEFT JOIN needs ON follow.username=needs.needsusername ORDER BY needs.datetime";
$lookupposts = mysql_query($sql) or trigger_error("Query Failed! SQL: $sql - Error: ".mysql_error(), E_USER_ERROR);
while ($postrow = mysql_fetch_array($lookupposts)) {
$description = $postrow['needs.description'];
$needsusername = $postrow['needs.needsusername'];
$datesubmitted = $postrow['needs.datesubmitted'];

echo "<b>User:</b> $needsusername<br><br><b>Description:</b><br>$description<br><br><b>Date Submitted:</b>  $datesubmitted<br><br>----------------------------------------<br><br>";

}



I didn't get an error but all it shows is

User:

Description:

Date Submitted:

but it doesn't show any info. stumped again. But I'm learning. Any direction?

#23 Jessica

Jessica

    This is not my name.

  • Gurus
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 25 February 2013 - 06:55 PM

You don't need the table alias when you print the row. Print_r($postrow)
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#24 derekshull

derekshull

    Advanced Member

  • Members
  • PipPipPip
  • 107 posts

Posted 25 February 2013 - 07:10 PM

Works great except one thing now.

For some reason it's showing my posts and the posts of one other user named "dvdowns" but not the posts of everyone I follow. It's strange.

#25 derekshull

derekshull

    Advanced Member

  • Members
  • PipPipPip
  • 107 posts

Posted 25 February 2013 - 07:21 PM

I've messed around and still can't figure out why it's showing my posts and the posts of only one person I follow. I don't think it's understanding that I'm following others besides that one user. So is it pulling all the people I follow?

#26 Jessica

Jessica

    This is not my name.

  • Gurus
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 25 February 2013 - 07:22 PM

You do still need to limit that query to your follows.

In phpmyadmin or mysql command line run SELECT * FROM follow WHERE username = 'Put your username here'; - what do you get?
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#27 Jessica

Jessica

    This is not my name.

  • Gurus
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 25 February 2013 - 07:25 PM

Also in the longrun you'll want to switch the order of your JOIN and probably just use INNER.

SELECT description, needsusername, datesubmitted 
FROM needs
INNER JOIN follow
ON follow.followname = needs.needsusername
AND follow.username = 'Your username here';

Is what I think you'll need based on your posts.
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#28 derekshull

derekshull

    Advanced Member

  • Members
  • PipPipPip
  • 107 posts

Posted 25 February 2013 - 07:28 PM

When I run that command I get:

Username Followname
derekshull dvdowns
derekshull ForgottenSong
derekshull test
derekshull owensinguatemala

#29 Jessica

Jessica

    This is not my name.

  • Gurus
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 25 February 2013 - 07:30 PM

So you do have several other users you're following. Try the other query I gave you in place of yours. 
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#30 derekshull

derekshull

    Advanced Member

  • Members
  • PipPipPip
  • 107 posts

Posted 25 February 2013 - 07:34 PM

I'm pretty sure it's solved. I'll mark it solved and go with it for now, thanks!

Also to the snide comment you made earlier, remember you're the 26 year old that started the sarcastic comments. My employees appreciate your "help".

#31 derekshull

derekshull

    Advanced Member

  • Members
  • PipPipPip
  • 107 posts

Posted 25 February 2013 - 07:35 PM

But all hard feelings aside: thank you, you really did end up helping.

#32 Jessica

Jessica

    This is not my name.

  • Gurus
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 25 February 2013 - 07:39 PM

Way to ensure you won't get my help again. This is why I don't usually write actual code for people. They act like assholes even when you give them what they want. Bite me.
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#33 AyKay47

AyKay47

    Sick!

  • Members
  • PipPipPip
  • 3,287 posts
  • LocationEast Coast, U.S.
  • Age:24

Posted 25 February 2013 - 08:35 PM

Gotta love it...
Hola!
I'm not going to hold your hand and write the code for you - ain't nobody got time for that!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com