aligning a table center in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rjhe22
Forum Newbie
Posts: 9
Joined: Fri Sep 24, 2010 9:57 am

aligning a table center in php

Post by rjhe22 »

hi
im trying to get my table to be in the middle of the page also want it to be a certain distance from the top of the webpage.
any ideas how to do this
this is my code

Code: Select all

</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div id="formHolder" align="right">
  <form name="form1" method="post" action="contactformprocess.php" >
    <table align="right" width="100%" border="0" cellspacing="0" cellpadding="6" >
      <tr>
        <td><label for="email">
            <div align="right">Email Address:</div>
          </label>
        </td>
        <td><div align="left">
          <input name="email" type="text" id="email" size="35" maxlength="100">
        </div></td>
      </tr>
      <tr>
        <td><label for="name">
            <div align="right">Name:</div>
          </label>
        </td>
        <td><div align="left">
          <input name="name" type="text" id="name" size="35" maxlength="80">
        </div></td>
      </tr>
      <tr>
        <td><label for="phone">
            <div align="right">Phone Number:</div>
          </label>
        </td>
        <td><div align="left">
          <input name="phone" type="text" id="phone" size="35" maxlength="12">
        </div></td>
      </tr>
      <tr>
        <td><div align="right">Response:</div></td>
        <td><p align="left">
          <label>
            <input type="radio" name="response" value="Yes I am interested in a meeting. Please contact me to arrange a meeting" id="budget_0">
            Yes I am interested in a meeting. Please contact me to arrange a meeting</label>
          <br>
          <label>
            <input type="radio" name="response" value="     Yes I am interested in a meeting but at a later date. Please contact me in a months time" id="budget_1">
            Yes I am interested in a meeting but at a later date. Please contact me in a months time</label>
          <br>
          <label>
            <input type="radio" name="response" value=" No I do not require a meeting" id="budget_2">
           No I do not require a meeting</label>
          
          <br>
        </p></td>
      </tr>
      <tr>
        
      <tr>
        <td><div align="right">
          <label for="clear"></label>
          <input type="reset" name="clear" id="clear" value="Reset Form">
        </div></td>
        <td><div align="right">
          <label for="submit"></label>
          <div align="left">
            <input type="submit" name="submit" id="submit" value="Send Email!">
          </div>
        </div></td>
      </tr>
    </table>
  </form>
  <p align="center">&nbsp; </p>
</div>
</body>
</html>
User avatar
DigitalMind
Forum Contributor
Posts: 152
Joined: Mon Sep 27, 2010 2:27 am
Location: Ukraine, Kharkov

Re: aligning a table center in php

Post by DigitalMind »

use css
rjhe22
Forum Newbie
Posts: 9
Joined: Fri Sep 24, 2010 9:57 am

Re: aligning a table center in php

Post by rjhe22 »

sorry let that bit out

Code: Select all

<style type="text/css">

<!--
body {
	background-color: #f1f1f1;
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-style: normal;
	line-height: normal;
	font-weight: normal;
	color: #666666;
	text-decoration: none;
	margin-top:150px;
	t
	
	
}
#formHolder {
	width: 800px;
	height:400px;
	background-color: e1e1e1;

}
do i just pick align center or is there a table align ??
itimeheke
Forum Newbie
Posts: 5
Joined: Mon Sep 27, 2010 5:10 am

Re: aligning a table center in php

Post by itimeheke »

Code: Select all

#formholder {
    margin: 10px auto 0px auto;
}
First argument(10px) in margin(distance) from top.
Second and fourth for left and right. Setting these both to 'auto' aligns to center.
Third one is for bottom.
rjhe22
Forum Newbie
Posts: 9
Joined: Fri Sep 24, 2010 9:57 am

Re: aligning a table center in php

Post by rjhe22 »

thanks very much for that it works perfect
Post Reply