Jump to content

Archived

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

khan kaka

php and sql

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:

 

Share this post


Link to post
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!

Share this post


Link to post
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:

Share this post


Link to post
Share on other sites

×

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.