I have this script to limit the output of a MySQL database so that when a string is detected to be more than 140 characters long the script treats it as 2 lines instead of one.
while($row = mysqli_fetch_array($result)) {
$stringl = "$input";
if ((strlen($stringl) > 140) && (!$_SESSION["" . $row['ID'] . ""]) && (!empty("".$_SESSION["text-lines"].""))) {
$_SESSION["" . $row['ID'] . ""] = "" . $row['ID'] . "";
$_SESSION["text-lines"] = $_SESSION["text-lines"] - 1;
}
I am storing the unique ID of the string in a session to avoid this code being ran again when the page is refreshed but it doesn't work:
Presently if one string contains more than 140 characters, 1 is deducted from the text-lines session every time the script is refreshed.
The expected result is for 1 to be deducted once from text-lines session and then that same line wouldn't be able to deduct another line from text-lines.