TinyPortal

Development => Support => Topic started by: pheasant_plucker on August 15, 2006, 09:16:43 PM

Title: It might be a dumb question but....
Post by: pheasant_plucker on August 15, 2006, 09:16:43 PM
How do I format text in a php block? I tried echo "</p><font face="Forte">","<font color="#FF0000" size="4"><b>Reserve Not Met</b></font></font>";   It just throws up a parse error!
I need to be able to change font colour, size and face if possible.

Gerry
Title: Re: It might be a dumb question but....
Post by: IchBin on August 15, 2006, 09:20:34 PM
Any time you're using the php echo statement with double quotes you have to comment out any double quotes inside the statement or use a single quote. Or you can do it the other way around and use single quotes with double quotes in your html like it normally would be.  I prefer to write my echo's like this.
echo '</p><font face="Forte"><font color="#FF0000" size="4"><b>Reserve Not Met</b></font></font>';

If you were to write it the way you want then you'd have to do this.
echo "</p><font face=\"Forte\"><font color=\"#FF0000\" size=\"4\"><b>Reserve Not Met</b></font></font>";

I also want to point out that you don't need the "," in your line of code either so I took it out.
Title: Re: It might be a dumb question but....
Post by: IchBin on August 15, 2006, 09:23:03 PM
curious why you have two <font> tags though.... ?
Title: Re: It might be a dumb question but....
Post by: pheasant_plucker on August 15, 2006, 09:27:00 PM
Two font tags are a copy/paste cockup when I was doing the post!
Thanks for the quick reply I shall give it a go.

Gerry
Title: Re: It might be a dumb question but....
Post by: IchBin on August 15, 2006, 09:28:38 PM
What I meant was that you can combine what you wrote I believe.
[code<font color=\"#FF0000\" size=\"4\" face=\"Forte\">
Title: Re: It might be a dumb question but....
Post by: pheasant_plucker on August 15, 2006, 09:32:47 PM
That works great thanks, I learn something new everyday!
One more question if you don't mind. In the same block I include a text file require("location of file ect/highbidderis.txt"); How could I change the font formatting on that?

Thanks for your help!
Gerry
Title: Re: It might be a dumb question but....
Post by: IchBin on August 15, 2006, 09:39:45 PM
You'd probably be better off doing the formatting in the actual text file. Otherwise, you'll be writing a big routine just to parse the files and then add the html to it. Thats the way I see it anyway, but I'm no PHP guru yet. Bloc could probably do something like this in his sleep.
Title: Re: It might be a dumb question but....
Post by: pheasant_plucker on August 15, 2006, 09:46:50 PM
I can't do it that way as the file is used as a database to store a variable number. I wrote a script for a simple auction for a site I administrate on which uses flat files for storage. I suppose I could call the file from a seperate php page, load the contents into a variable then include that page instead. Then I should be able to do something along the lines of echo '</p><font face="Forte"><font color="#FF0000" size="4"><b>$variable</b></font></font>';

Gerry
Title: Re: It might be a dumb question but....
Post by: IchBin on August 15, 2006, 10:04:34 PM
Can you give me an example of some of the lines in your files? I'd like to play with this and see what I can come up with. No promises though.
Title: Re: It might be a dumb question but....
Post by: pheasant_plucker on August 15, 2006, 10:21:22 PM
The content of the file in question would be (at this very moment)
QuoteThe current High Bid is from imagedktr With a Bid of Ã,£10
obviously the bidders name and amount changes with every successful bid!
This is written into the file from the main auction php script. Including the file simply displays the above text.

Gerry
Title: Re: It might be a dumb question but....
Post by: IchBin on August 15, 2006, 10:30:57 PM
So it's only going to be one line each time someone bids? Its never going to be more than that? That shouldn't be too hard I think.
Title: Re: It might be a dumb question but....
Post by: pheasant_plucker on August 15, 2006, 10:34:25 PM
Each time the bid is higher anyway! I suppose I could write the formatting to the text file then simply read the lot back into the block if that would work i.e. the file content would become echo '</p><font face="Forte"><font color="#FF0000" size="4"><b>The current High Bid is from imagedktr With a Bid of ÂÃ,£10</b></font></font>';

Gerry
Title: Re: It might be a dumb question but....
Post by: bloc on August 16, 2006, 10:43:25 PM
If its a set style you want on this, maybe simply do this:


echo '<span style="font: Forte #FF0000 large bold;">';
require("location of file ect/highbidderis.txt");
echo '</span>';
Title: Re: It might be a dumb question but....
Post by: pheasant_plucker on August 17, 2006, 09:42:08 AM
Thanks Block but that has no effect at all to the formatting of the text! There's probably a simple explanation to this but it's proving elusive to me.

Gerry
Title: Re: It might be a dumb question but....
Post by: bloc on August 17, 2006, 01:28:54 PM
The file you include..maybe better to simply include the formatting in it I think.