Issue fixed, Close thread.

Marcel

You're the guy who stole my car
Jul 17, 2015
466
208
<?php
$to5 = mysql_query("SELECT * FROM cms_news ORDER BY ID DESC LIMIT 1") or die(mysql_error());
?>
I prefer if it would just be specific and not by order as I want to put id article 2 and not show the rest.
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
Rather than hard coding you could also make it a bit more elaborate.
- I just used a premade table called "texts" which holds all your captioning on your hotel, just to have a field that will handle the news you want, this way you can add a page to change it VIA Housekeeping, and you can change it easily in the database without having to open up the page EVERY TIME.
- You have to fetch the assoc in order to grab fields otherwise you won't be able to use the information
- If you want to use this same setup, open your texts table and add identifier = "news_id" and display_text = "2" or whatever one you need.

//Get
$setID = mysql_fetch_assoc(mysql_query("SELECT `display_text` FROM `texts` WHERE `identifier` = 'news_id'"));
$news = mysql_query("SELECT * FROM cms_news WHERE id = '".$setID['setID']."'");

- You can use this to simply post a form to update the news ID in your housekeeping
//Set
<?php
if(isset($_POST['newsID']){
$newID = filter($_POST['newsID']);
if(is_numeric($newID)){
mysql_query("UPDATE `texts` SET `news_id` = '".$newID."' WHERE `identifier = 'news_id'");
}else{
echo "Not Numeric";
}
}

None of this code is testing, I just coded it on my phone. Enjoy :)
 

Marcel

You're the guy who stole my car
Jul 17, 2015
466
208
Rather than hard coding you could also make it a bit more elaborate.
- I just used a premade table called "texts" which holds all your captioning on your hotel, just to have a field that will handle the news you want, this way you can add a page to change it VIA Housekeeping, and you can change it easily in the database without having to open up the page EVERY TIME.
- You have to fetch the assoc in order to grab fields otherwise you won't be able to use the information
- If you want to use this same setup, open your texts table and add identifier = "news_id" and display_text = "2" or whatever one you need.

//Get
$setID = mysql_fetch_assoc(mysql_query("SELECT `display_text` FROM `texts` WHERE `identifier` = 'news_id'"));
$news = mysql_query("SELECT * FROM cms_news WHERE id = '".$setID['setID']."'");

- You can use this to simply post a form to update the news ID in your housekeeping
//Set
<?php
if(isset($_POST['newsID']){
$newID = filter($_POST['newsID']);
if(is_numeric($newID)){
mysql_query("UPDATE `texts` SET `news_id` = '".$newID."' WHERE `identifier = 'news_id'");
}else{
echo "Not Numeric";
}
}

None of this code is testing, I just coded it on my phone. Enjoy :)
Nice, I'll try it out.
Thanks heaps.
 

Users who are viewing this thread

Top