|
Posted by BlackSpider on 10/04/06 10:07
So I've now tried...
function TableData($slot)
{
global $row_Recordset1, $colour_FREE, $colour_TOOK;
$var = "'"."$slot"."'";
if ($row_Recordset1[$var] == "") {
return ($colour_FREE.'" class="timeslot"><div
align="center">'.$row_Recordset[$var]);
}
else {
return ($colour_TOOK.'" class="timeslot"><div
align="center">'.$row_Recordset1[$var]);
}
}
.... To no avail, $row_Recordset[$var] still returns nothing, even though if
I manually input "date" instead of "$var", it works fine. (Yes, $slot is
returning "date" correctly)
Incase I misunderstood, I also tried calling the function using
"'"."data"."'" as the argument, (Both directly, and through a secondary
string (TableData($var)) but that didn't work either. :(
"Vince Morgan" <vinhar@UNSPAMoptusnet.com.au> wrote in message
news:45237850$0$22938$afc38c87@news.optusnet.com.au...
>
> "BlackSpider" <BlackSpider@I.Dont.Exist.com> wrote in message
> news:v5ednayzlo_lYr_YRVnytQ@eclipse.net.uk...
>> <--PHP
>> function TableData($slot)
>> {
>> global $row_Recordset1, $colour_FREE, $colour_TOOK;
>>
>> $slotuser = $row_Recordset1[$slot];
>> if ($slotuser == "") {
>> return ($colour_FREE.'" class="timeslot"><div
>> align="center">'.$slotuser );
>> }
>> else {
>> return ($colour_TOOK . '" class="timeslot"><div align="center">'
>> .
>> $row_Recordset1[ $slot ]);
>> }
>>
>> }
>> PHP-->
>>
>> The $row_Recordset1 array is set by mysql_fetch_assoc to get some table
>> data, and I call this function with the table-row name (In this case
>> "date"), like this: TableData('date')
>>
>> However, when trying to get the data of the row 'date' from the Record
> using
>> $slot, it returns a null string, regardless of what data is actually
> there.
>> If I replace $slot with 'date' in the code, it returns the correct value,
> so
>> the connection between php/Mysql is fine, but when trying to get the data
> by
>> using a String as the Key, it simply doesn' twork. Any ideas?
>>
>>
> I think you may need to append single quotes to get it to work.
>
> $var = "'"."table-row name "."'";
>
>
> HTH
> Vince Morgan
>
>
Navigation:
[Reply to this message]
|