Forum Moderators: open

Message Too Old, No Replies

select finding no data

         

seanollett

9:20 pm on Mar 9, 2006 (gmt 0)

10+ Year Member



I think I must have the settings for mysql wrong. I am using mysql 5 with php4 on apache on a windows xp computer.

My problem is that I am creating a blog using dreamweaver. I create a recordset from a database and bind it to the page. Then, when i want to display some of the data from the record set, i do select etc and end up with something like this:

SELECT blg_article_art.id_art, blg_topic_top.id_top, blg_topic_top.title_top, blg_article_art.title_art, blg_article_art.description_art, blg_article_art.date_art, blg_article_art.text_art
FROM (blg_topic_top LEFT JOIN blg_article_art ON blg_article_art.idtop_art=blg_topic_top.id_top)
WHERE blg_article_art.id_art=id_art
ORDER BY blg_article_art.id_art ASC, blg_article_art.date_art DESC

Now the url parameter (WHERE blg_article_art.id_art=id_art) has a default value of -1 but when I test the statement I get no data found. If i change the default value to 0 or a positive integer then one of the records is found but only one. I am trying to get it to display a single article from from a set of articles based on the is of the article.

I have tried this with another database and get the same thing which makes me think either I have mysql set up incorrectly (although it works for all the other record sets that do not have -1) or I am very, very thick.

Sorry for the length of this.

Any miracles would be greatly appreciated.

Regards

Sean

Demaestro

10:08 pm on Mar 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



try this (I changed the where statement):

SELECT blg_article_art.id_art, blg_topic_top.id_top, blg_topic_top.title_top, blg_article_art.title_art, blg_article_art.description_art, blg_article_art.date_art, blg_article_art.text_art
FROM (blg_topic_top LEFT JOIN blg_article_art ON blg_article_art.idtop_art=blg_topic_top.id_top)
WHERE (blg_article_art.id_art=id_art or blg_topic_top.id_art=id_art)
ORDER BY blg_article_art.id_art ASC, blg_article_art.date_art DESC

Let me know if that works, if not I will take another stab at it for you.

seanollett

6:27 pm on Mar 10, 2006 (gmt 0)

10+ Year Member



thanks a lot. I shall give it a try and let you know.

Regards