Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The RSS feed doesn't have random IDs. You are inserting a random ID, which you want to not be random. (I don't even know why you want an ID.) </p> <p>If you just take the numbers from their guid, you would have a unique ID that will serve your needs. All you have right now is a fake ID.</p> <p>Added: IDs are very rarely 'random' in any sensible project. You want an ID that stays the same. Presumably, you also do not want two stories to have the same ID. Therefore what you need is not a random number, but to assign a random-looking number to each new entry. </p> <p>You cannot do this without a database (although you could use a flat file database). The table needs two columns - 'ArticleID' and 'RandomID'.</p> <p>You need to find an item in the feed that is unique and does not change, so that you can recognise it again. News titles do change, so the numbers in the BBC's GUID should be your best bet.</p> <p>What you then need to do is take this ArticleID number and DB query for a matching row to get an existing RandomID. If there isn't one, keep generating a random number in your current fashion and checking to see if the RandomID is already used until you find a new unused random number. Then insert a new row with ArticleID and RandomID, using the new RandomID for whatever crazy purpose you have.</p> <p>You could also generate a set of unused random numbers ahead of time. You may also wish to introduce a datestamp or an auto-increment ID so you could more easily delete old article/randomID combinations when eventually necessary.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload