Professional Web Applications Themes

Displaying a DB item from an RSS link - MySQL

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

  1. #1

    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?
    builder Guest

  2. #2

    Default Re: Displaying a DB item from an RSS link

    On Sat, 28 Oct 2006 11:41:53 -0400, builder wrote: 

    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.
     

    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)

    --
    It seems that we were audited recently, and the auditors found a certain
    'f' word in the comments of a configuration file, and deemed that this
    is a 'security risk'.
    -- Paul Fenwick
    Peter Guest

  3. #3

    Default Re: Displaying a DB item from an RSS link

    Peter H. Coffin wrote: 
    >
    >
    > 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.
    >

    >
    >
    > 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)[/ref]

    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 Guest

  4. #4

    Default Re: Displaying a DB item from an RSS link

    builder wrote:
     

    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!
    builder Guest

Similar Threads

  1. Combox Box not displaying selected item
    By kdennis4 in forum Macromedia Flex General Discussion
    Replies: 8
    Last Post: April 19th, 01:15 AM
  2. e.Item.ItemIndex and e.Item.DataSetIndex
    By Scott M. in forum ASP.NET Data Grid Control
    Replies: 5
    Last Post: April 13th, 05:40 AM
  3. make web link in illustrator, save as eps, distill to pdf, retain link?
    By George_McKim@adobeforums.com in forum Adobe Illustrator Macintosh
    Replies: 7
    Last Post: June 23rd, 06:37 PM
  4. Replies: 2
    Last Post: February 5th, 12:11 AM
  5. Replies: 6
    Last Post: January 17th, 07:46 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139