MichaelHooker
Programmer
The last three times I have started drafting a question here I've thought of the answer before I got to the end, so here's hoping.
This has me baffled. I take a row of data out of the MySQL database and put it together into a string, like so:
Note that square brackets are inserted around $row[8]. This creates a nicely-formatted string in the standard style for this type of data.
$details is later inserted into a standard html data table cell.
Sometimes, there is no data to retrieve, the $row array is empty and so $details consists only of the square brackets, as '[]'. In that case I would like to display '---' in the table cell instead. So please will someone tell me why the following substitution does not work?
"[]" stubbornly remains "[]". I have checked very carefully for unwanted spaces (like "[ ]" or " [ ]" but can't find any.
I have thought of a work-around, which works:
but I'd still like to know why the first code does not work. Is it not possible to reassign the value of a string used in the if test? I do this all the time in Delphi
Many thanks
Michael Hooker
This has me baffled. I take a row of data out of the MySQL database and put it together into a string, like so:
Code:
$details = $row[4] . ' ' . $row[5] . $row[6] . ' ' . $row[7] . ' [' . $row[8] . ']';
$details is later inserted into a standard html data table cell.
Sometimes, there is no data to retrieve, the $row array is empty and so $details consists only of the square brackets, as '[]'. In that case I would like to display '---' in the table cell instead. So please will someone tell me why the following substitution does not work?
Code:
if ($details == '[]') {
$details = '---' ;
}
I have thought of a work-around, which works:
Code:
if ($row[4] == '') {
$details = '---' ;
}
Many thanks
Michael Hooker