Jump to content

Jaynesh

Members
  • Posts

    64
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Jaynesh's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello How do I detect a url from a bunch of text? I don't want to turn the url into a link, I want to echo the link on its own. For e.g $text = 'hello this is my website www.google.com' I would like to detect the url in the above text, and echo just the url.
  2. Is this possible? (in red) LEFT JOIN Friends ON dbPosts.username_id = dbFriends.friend_id OR dbPosts.username_id = $myid
  3. Hello I am very confused and frustrated here. What relationship does the columns in SELECT have with the actual JOIN query. Ive got these three tables in my SELECT dbUsers.*, dbPosts.*, dbKarma.* but when I add a fourth table dbUsers.*, dbPosts.*, dbKarma.*, dbPosts_share.* the whole query stops outputting results. What relationship does the SELECT have with the JOIN query? Why would this effect the query? As far as I know, SELECT is for the actual output in the loop?
  4. Hi I have already setup a timestamp in my table. How would I compare the difference? This is the format on my timestamp: 0000-00-00 00:00:00
  5. Hello Ive got a table post(post_id, user_id, post, timestamp) when a post is outputted I want it to display how many minutes/hours ago it was posted. How would I do this? I'm assuming it requires math? For e.g This is my post Submitted 2 hours and 32 minutes ago
  6. Hello I have a table posts(user_id, post_id, post) I want to add a time stamp to each post. Is it ideal to store timestamps in a separate table or in the same table?
  7. Hi. Yes but how can I add this into the query. for e.g $query = "SELECT $select //from FROM dbPosts //left join LEFT JOIN dbUsers ON dbPosts.username_id = dbUsers.id //left LEFT JOIN dbFriends ON (dbPosts.username_id = dbFriends.my_id)"
  8. hi is it possible to add comments in sql queries. my sql query has gotten so complicated to the point that I don't know which part does what.
  9. Hi, I've setup a simple system. where a user can make a post and it will be visible to his friends. His/her friends can then place a vote on that post. These are my tables. users(id, username) 1 John 2 Mary 3 Jacob friends(my_id, friend_id) 1 2 1 3 3 2 posts(post_id, user_id, post) 1 1 John's post 2 3 Jacob's post 3 2 Mary's post vote(user_id, post_id, up, down) 1 1 1 0 2 1 0 1 This is my query. "SELECT DISTINCT dbUsers.*, dbPosts.*, dbKarma.*; FROM posts LEFT JOIN users ON posts.username_id = users.id LEFT JOIN friends ON (posts.username_id = friends.my_id) OR (posts.username_id = friends.friend_id) LEFT JOIN vote ON posts.post_id = vote.post_id The problem is if there is more then 1 vote on a particular post, it will be duplicated. If there are 2 votes on that post it will be duplicated twice.. and 3 votes, duplicated three times. Why is this happening?
  10. Hi is it possible to add AND to a join query? if so what is the correct method. Ive tried this but it doesnt work. LEFT JOIN dbKarma ON dbPosts.post_id = dbKarma.karma_post_id AND dbPosts.user_id = dbKarma.karma_user_id
  11. Hello I have three tables. users(user_id, username) posts(post_id, user_id, post) vote(post_id, up, down) I have joined vote(post_id) with posts(post_id) if post_id has 3 duplicate data, it will output my data 3 times. How do I make it so it only outputs once?
  12. Hello the up and down columns are not part of my query because my query is all linked with joins. How do I put those two columns in my query just for this?
  13. hello I'm working on a basic script where users can post things. On each post how do a display the time and how many hours ago it was posted? For e.g Jacob - this is my post Posted 6 hours ago
  14. Hello I have three tables users(user id, vote id) posts(post id, user id, post) vote(vote id, post id, up, down) This is my while loop. It outputs all the posts users have made. each post has a box around it. My div id 'postbox' is stored in a seperate CSS file containing a colour value. How do I change the colour value depending on data in vote(up, down) while( $i < $row = mysql_fetch_array($query)) { echo "<div id=" . "postbox". ">"; echo $row['post']; echo "</div>; }
  15. Hello I have an sql query which is working perfectly. SELECT DISTINCT dbPosts.post FROM dbPosts LEFT JOIN ( dbUsers, dbFriends, dbPosts_share ) ON ( dbPosts.username_id = dbUsers.id AND (dbPosts.username_id = dbFriends.user_id) OR (dbPosts.username_id = dbFriends.friend_id) ) but when I add an extra column, it duplicates each output several times. SELECT DISTINCT dbPosts.post, dbUsers.username FROM dbPosts LEFT JOIN ( dbUsers, dbFriends, dbPosts_share ) ON ( dbPosts.username_id = dbUsers.id AND (dbPosts.username_id = dbFriends.user_id) OR (dbPosts.username_id = dbFriends.friend_id) ) Why is this happening?
×
×
  • 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.