Ever since LabourStart was founded we’ve had top priority news stories in English followed by lesser priority ones, but have never done this for our other 21 languages. Until now.
Now we have the capacity to do this and I’ve added some lines of code to our PHP script that generates our front pages — but it’s not working. I run a PHP function (readdb) twice, like this:
readdb (3,5);
readdb (2,100);
The first number is the story’s priority (taken from our database) and the second is the maximum number of stories to show.
Then I call the function like this:
function readdb ($ipriority,$totalstories) {
But it’s not working as I’d hoped.
This is really a matter of getting the syntax right — and nothing I’m trying seems to work.
I want to tell the system to get all records from a table called “news” where the priority is either 2 or 3 and where the language code is a 2 or 3 character code, and then to sort by date and within date, by the date and time the story was entered into our database. This is the line that’s causing all the problems — remember that priority is a numeric field and language is text:
$query = “SELECT * FROM news WHERE priority = $ipriority AND language = ‘$langcode’ ORDER BY date DESC, dateposted DESC LIMIT $totalstories”;
Can anyone help? Thanks!