Re: [PHP] Change styling depending on var value

2009-11-23 Thread Phil Matt
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

Re: [PHP] Change styling depending on var value

2009-11-20 Thread Mari Masuda
On Nov 20, 2009, at 2:29 PM, Ashley Sheridan wrote: > On Fri, 2009-11-20 at 17:23 -0500, Phil Matt wrote: > >> 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

Re: [PHP] Change styling depending on var value

2009-11-20 Thread Ashley Sheridan
On Fri, 2009-11-20 at 17:23 -0500, Phil Matt wrote: > 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 That means that

Re: [PHP] Change styling depending on var value

2009-11-20 Thread Phil Matt
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

Re: [PHP] Change styling depending on var value

2009-11-20 Thread Ashley Sheridan
On Fri, 2009-11-20 at 17:08 -0500, Phil Matt wrote: > 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: > >

Re: [PHP] Change styling depending on var value

2009-11-20 Thread Phil Matt
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

Re: [PHP] Change styling depending on var value

2009-11-20 Thread Ashley Sheridan
On Fri, 2009-11-20 at 16:41 -0500, Phil Matt wrote: > 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

Re: [PHP] Change styling depending on var value

2009-11-20 Thread Phil Matt
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

RE: [PHP] Change styling depending on var value

2009-11-20 Thread Ford, Mike
> -Original Message- > From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] > Sent: 20 November 2009 21:16 > To: Phil Matt > Cc: php-general@lists.php.net > Subject: Re: [PHP] Change styling depending on var value > > On Fri, 2009-11-20 at 16:17 -0500, Phil M

Re: [PHP] Change styling depending on var value

2009-11-20 Thread Ashley Sheridan
On Fri, 2009-11-20 at 16:17 -0500, Phil Matt wrote: > Ashley Sheridan wrote: > > > copy the results of this: > > > > vardump($row); > > > Sirloin SteakfreshAcmemeat > Chicken Breast frozen Acmemeat > Decaf Columbian pantry Giant coffee > Ice

Re: [PHP] Change styling depending on var value

2009-11-20 Thread Phil Matt
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

Re: [PHP] Change styling depending on var value

2009-11-20 Thread Ashley Sheridan
On Fri, 2009-11-20 at 15:52 -0500, Phil Matt wrote: > 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

Re: [PHP] Change styling depending on var value

2009-11-20 Thread Phil Matt
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.

Re: [PHP] Change styling depending on var value

2009-11-20 Thread Phil Matt
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

Re: [PHP] Change styling depending on var value

2009-11-20 Thread Dan McCullough
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. On Fri, Nov 20, 2009 at 3:16

Re: [PHP] Change styling depending on var value

2009-11-20 Thread Ashley Sheridan
On Fri, 2009-11-20 at 15:30 -0500, Phil Matt wrote: > Ashley Sheridan wrote: > > > print $row[3]; > > > > Does it contain a string like you expect? > > > > Yes. I'm going to try the same kind of formatting on a different $row > cell and see what happens. > > Cheers and thanks again --- Phil

Re: [PHP] Change styling depending on var value

2009-11-20 Thread Ashley Sheridan
On Fri, 2009-11-20 at 15:11 -0500, Phil Matt wrote: > Ashley Sheridan wrote: > > > Well, you're main problem here is that you are only using a single = > > character. What that is saying to PHP is: "if you let me assign the > > value of $beverage to $row[3] then do this next bit", but what I th

Re: [PHP] Change styling depending on var value

2009-11-20 Thread Ashley Sheridan
On Fri, 2009-11-20 at 14:45 -0500, Phil Matt wrote: > 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,