Displaying a DB item from an RSS link

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 ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-28-2006
builder
 
Posts: n/a
Default Displaying a DB item from an RSS link

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?
Reply With Quote
  #2 (permalink)  
Old 10-28-2006
builder
 
Posts: n/a
Default Re: Displaying a DB item from an RSS link

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.
Reply With Quote
  #3 (permalink)  
Old 10-28-2006
builder
 
Posts: n/a
Default Re: Displaying a DB item from an RSS link

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!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:44 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0