This is a discussion on Displaying a DB item from an RSS link within the MySQL Database forums, part of the Database Forums category; MySQL is not my strong suit. ;) I'm trying to set up an RSS feed where each item when clicked ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
MySQL is not my strong suit. ;) I'm trying to set up an RSS feed where
each item when clicked on would be directed to another page for more information to be displayed. The additional information would be extracted from the database table and be displayed dynamically on a new page. But I can't seem to get the right phrasing to make it happen. I'm using this format - www.mydomain.com/rssdisplay.htm#24 - as the link that forwards to the new page which is called rssdisplay.htm. What I need to do is pull ID# 24 (or whatever other one that is requested) from the table and display it. But I can't come up with how. I thought this would work: $referer = $_SERVER['HTTP_REFERER']; $ids = explode("#", $referer); $ids = $ids[1]; $select = "SELECT * FROM `news` WHERE `ID` LIKE $ids"; but it doesn't. And it doesn't throw an error, just does nothing. :( If I echo $ids[1], I get nothing. What am I doing wrong here? |
|
|||
|
Peter H. Coffin wrote:
> On Sat, 28 Oct 2006 11:41:53 -0400, builder wrote: > >>MySQL is not my strong suit. ;) I'm trying to set up an RSS feed where >>each item when clicked on would be directed to another page for more >>information to be displayed. The additional information would be >>extracted from the database table and be displayed dynamically on a new >>page. But I can't seem to get the right phrasing to make it happen. >> >>I'm using this format - www.mydomain.com/rssdisplay.htm#24 - as the link >>that forwards to the new page which is called rssdisplay.htm. What I >>need to do is pull ID# 24 (or whatever other one that is requested) from >>the table and display it. But I can't come up with how. >> >>I thought this would work: >> >>$referer = $_SERVER['HTTP_REFERER']; >>$ids = explode("#", $referer); >>$ids = $ids[1]; > > > Are you sure you want to use $ids for both of the above lines? I'm not > sure, but in some languages, assigning scalars to things that are > defined as structures does special things. Which may not be what you > want here. > > >>$select = "SELECT * FROM `news` WHERE `ID` LIKE $ids"; >> >>but it doesn't. And it doesn't throw an error, just does nothing. :( If >>I echo $ids[1], I get nothing. > > > Nothing won't match to anything with a LIKE... > > mysql> create table foo ( col1 varchar (30), col2 varchar (30)); > Query OK, 0 rows affected (0.10 sec) > > mysql> insert into foo values ('test 1', 'test 2'); > Query OK, 1 row affected (0.00 sec) > > mysql> select * from foo where col2 like ''; > Empty set (0.00 sec) > > mysql> select * from foo where col2 like 'test'; > Empty set (0.00 sec) > > mysql> select * from foo where col2 like 'test%'; > +--------+--------+ > | col1 | col2 | > +--------+--------+ > | test 1 | test 2 | > +--------+--------+ > 1 row in set (0.00 sec) Okay, I understand how MySQL pulls the correct ID from your example. But in my situation I need to get the value of "test" (the number following # that the link contained) in order to write the select correctly. What I'm having trouble with is determining what that # value (which will also be the ID number in the table) that it is looking for actually is. I thought that exploding my example on the # would give me an array with two parts (www.mydomain.com[0] and 24[1]) but I'm obviously wrong in my thinking. |
|
|||
|
builder wrote:
> > Okay, I understand how MySQL pulls the correct ID from your example. But > in my situation I need to get the value of "test" (the number following > # that the link contained) in order to write the select correctly. What > I'm having trouble with is determining what that # value (which will > also be the ID number in the table) that it is looking for actually is. > > I thought that exploding my example on the # would give me an array with > two parts (www.mydomain.com[0] and 24[1]) but I'm obviously wrong in my > thinking. Found my problem. Was using $_SERVER['HTTP_REFERER'] instead of $_SERVER['REQUEST_URI']. Turns out I had the right idea all along but was using the wrong $_SERVER variable. I have it working properly now. Thanks! |
![]() |
| Thread Tools | |
| Display Modes | |
|
|