Jump to content

Recommended Posts

how can i ask the sql to display results from two diffrent tables. wich feedid is = to id from diffrentt able

==============================

SELECT content.id, messeges.feedid

FROM messeges, content

WHERE messeges.feedid = content.id

===========================

i have designed a web log and on each topic i want others to be able to gave thier feed back. soo when user clicks on post feed back button i pass the id of topic to form by url and soo the feed back table has a field named feedid wich is equal to id of the topic.

 

on main page i want to be able to display how money responds have been saved for each topic. i used the code above but all the topics shows same amount of responds.

 

i am going crazy wiht this problem. thanks alot :unsure:

 

Link to comment
https://forums.phpfreaks.com/topic/2104-php-and-sql/
Share on other sites

how can i  ask the sql to display results from two diffrent tables. wich feedid is = to id from diffrentt able

==============================

SELECT content.id, messeges.feedid

FROM messeges, content 

WHERE messeges.feedid = content.id

===========================

i have designed a web log and on each topic i want others to be able to gave thier feed back. soo when user clicks on post feed back button i pass the id of topic to form by url and soo the feed back table has a field named  feedid wich is equal to id of the topic.

 

on main page i want to be able to display how money responds have been saved for each topic.  i used the code above but all the topics shows same amount of responds. 

 

  i am going crazy wiht this problem.  thanks alot  :unsure:

186228[/snapback]

 

in your query, you are only telling the database to give you every entry that has a matching id. that is going to return every entry every time. what you have to do to limit it is also provide the id of the content you want to get the number of results for. you need to do something like:

SELECT content.id, messages.feedid FROM messages, content WHERE messages.feedid = content.id AND messages.feedid = '1';

 

you could also do something like this:

SELECT COUNT(*) AS count, messages.feedid FROM message, content WHERE messages.feedid = content.id GROUP BY messages.feedid;

 

this query will return you a table with two columns: count and id. then, you just need to loop through all your results to see how many entries you have in a given id.

 

hope this helps!

Link to comment
https://forums.phpfreaks.com/topic/2104-php-and-sql/#findComment-6896
Share on other sites

in your query, you are only telling the database to give you every entry that has a matching id.  that is going to return every entry every time.  what you have to do to limit it is also provide the id of the content you want to get the number of results for. you need to do something like:

SELECT content.id, messages.feedid FROM messages, content WHERE messages.feedid = content.id AND messages.feedid = '1';

 

you could also do something like this:

SELECT COUNT(*) AS count, messages.feedid FROM message, content WHERE messages.feedid = content.id GROUP BY messages.feedid;

 

this query will return you a table with two columns: count and id.  then, you just need to loop through all your results to see how many entries you have in a given id.

 

hope this helps!

186304[/snapback]

 

===============================

 

hi there thanks very much for you respond but it seems to be working when i try the code in dreamweaver recordset window when i test the counting it works but on the page once agin it shows the frist count on all fields.

 

i have used repeat region server on table soo when it repeats on fields it shows the same count for all rpeated fileds. any idea :unsure:

Link to comment
https://forums.phpfreaks.com/topic/2104-php-and-sql/#findComment-6899
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.