Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using percent

Status
Not open for further replies.

RhythmAce

Technical User
May 22, 2001
2,869
FR
I looked high and low for a solution to this but since nobody seems to have ever asked this question, I assume I'm the only one who doesn't know the answer. I have a situation where I need to put an image and some text into tables on the page. Every thing is fine if I use a pixel size like <td width='170'...>. However, I'd like to use a percentage but <td width='20%'...> doesn't get it. This is within an echo statement so I have to use single quotes or escape the double quotes with a backslash. Here is the line of code I'm having trouble with.

Code:
  print("<td><table border='0' width='20%'><td align='center'><img src='images/candle.gif' width='70' height='79'><br>$name</td></table></td>");

I am in the process of creating a memorial website for my nephew. This particular code is for a page where people can light and a memorial candle. They will use a form to enter their name and a few words. When they click on a "submit" button, a candle is displayed with their name and message under it. This is why I have a table within a table. I want to have a limit of four candles per row so I have a short little routine to do that. Every thing seems to work well but I want to use a percentage so things don't get messed up for those who have wide screens.

 
Hi RhythmAce,

I could see nothing wrong in your print statement(syntaxwsie). Please post this query in HTML forum. The people out there will be able to help you.

--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
OK thanks. I was thinking that there was something special about the percent sign in php. I use tables quite a bit on this site and tend to embed a lot of html into the php pages. I have no problem when I use the percent sign in the html code on the rest of the page. Is there a way I can query mysql in php then pass the data to html to display?
 
Is there a way I can query mysql in php then pass the data to html to display?
Yes, that's what PHP is all about. If you choose just about any thread at random on the PHP forum you'll probabbly see an example.
What in particular did you want to do ?
 
I want to be able to use a percentage for the table width instead of a fixed pixel width. Everything is fine as long as I put width='170' but when I put width='20%', the table width is ignored. I guess I wasn't clear that there is no problem with the data being displayed. It is just I have to use a fixed width instead of a percentage. If I try to put that line of code in an html block, just the variable $name is displayed instead of its data.
 
there is nothing wrong with your code. browsers see table sizes as more or less advisory. percentages will work in certain circs and on certain browsers. take spookie's excellent advice and ask in the html forum. they will _definitely_ be able to fix this for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top