Ok, This is HOPEFULLY simple question so i put it in noobs.
Iam fairly new at PHP OOP, however im giving it ago and seeing what i come up with. During this change to more sophisticated programming i decided that id use some more functions. One of which id seen used alot is the return() function. However, inevitably i ahve run into problems.
I havea function which determins which type of date format a user would like according to their account settings in MySQL.
It will then return the approriate setup.
However, I wish to sue this function within a while loop which is in another function. If i dont have the 1st function the loop runs fine. however as soon as i add my new fancy function it stops after one run. Fancy taking a peak and seeing if there is anything wrong?
//fancy timestamp function :) oooooooohhh
function PrepareTimestamp($day,$month,$year) {
global $SQL;
if ($_SESSION['SPuserID'] == "guest") {
//default
$this->timestamp = "".$month."/".$day."/".$year;
} else {
//user specific
$query = "SELECT time_format
FROM userinfo WHERE username='".$_SESSION['SPuserID']."'";
$SQL->query_db($query);
$tformat = $SQL->fetch_row();
if ($tformat['time_format'] == "ddmmyyyy") {
$this->timestamp = "".$day."/".$month."/".$year;
} else {
$this->timestamp = "".$month."/".$day."/".$year;
}
}
return $this->timestamp;
} // End PrepareTimestamp();
//while loop function bla bla
function loop() {
while (something is true) {
echo "hello world";
echo PrepareTimestamp();
}
Obviously not the actualy function with the loop but its the idea... 🙂