De-lurking here.
I'm trying, with no success, to use some CSS styling on my PHP output.
Here's the code I want to style:
echo ''.$row[0].''.$row[1].'
I want to use a CSS style for the second cell, picking up the style
from the value of a variable. I tried this:
$newcolor = "color: red";
'
I am trying to style HTML table cells depending on the values stored in
a MySQL db. Thanks to other on this list, I can now refer to the
variable that holds a CSS styling value.
Now, I need to apply different values of that variable, depending on the
content of the table cell itself.
I tried
Ashley Sheridan wrote:
Copying back the phplist *again*!
Sorry. I'll remember to copy in...
what does your code currently look like now, with the right == in?
$entree="meat";
$beverage="coffee";
if ($row[3] == $entree)
{
$newcolor="color:red";
}
elseif ($row[3] == $beverage)
{
$newcol
Dan McCullough wrote:
To add to what Ashley said about $row[3], remember that when you are
returning from the db the counter for fields will start at 0 not 1, so
if its the 3rd field that will be $row[2]. You might also want to do
switch rather then elseif but thats always a good debate.
Jônatas Zechim wrote:
Try:
echo '' . $row[1] . '';
Thanks, Jônatas. This was the solution.
Cheers --- Phil
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Ashley Sheridan wrote:
copy the results of this:
vardump($row);
Sirloin Steak freshAcmemeat
Chicken Breast frozen Acmemeat
Decaf Columbianpantry Giant coffee
Ice Cream frozen Giant dessert
All looks as expected.
NB: This is just te
Ashley Sheridan wrote:
That's not a vardump, a vardump would contain the type of variable. I
wanted to see the whole thing.
I played with this for a while and checked the PHP manual; not sure how
to use this.
Cheers --- Phil
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe
Ashley Sheridan wrote:
As Mike pointed out, I meant var_dump(), sorry!
Is the idea to put the variable in question within the parentheses?
I tried the statement,
var_dump($row[3];
And I got in the output:
NULL
Also tried
var_dump();
And I got in the output:
Warning: Wrong parameter co
Ashley Sheridan wrote:
put
var_dump($row);
I inserted this line in the script at the end of the html table, still
inside the PHP echo statement.
This yields:
bool(false)
Cheers --- Phil
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Mari Masuda wrote:
This may be a dumb question, but did you actually fetch the db query's results
and put them in $row before trying to use $row? In MySQL you could do
something like:
$query = "select * from my_table";
$result = mysql_query($query);
$row = mysql_fetch_array($result); //this
e other statement
go?
header("Location:error.shtml");
TIA for any advice you can offer. I must be really missing the point here.
Cheers --- Phil Matt
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
11 matches
Mail list logo