Jump to content

Recommended Posts

This is probably a html problem but is there a way I can align my textboxes? At present they are straight after their tittles and it looks messy

 

my code is

 

<?
include("connect.php");
// now you are connected and can query the database

if(!empty($_POST['ID'])){
$ID=$_POST['ID'];
$Fname=$_POST['Fname'];
$Sname=$_POST['Sname'];
$Station=$_POST['Station'];
$Address1=$_POST['Address1'];
$Address2=$_POST['Address2'];
$Address3=$_POST['Address3'];
$Address4=$_POST['Address4'];
$Division=$_POST['Division'];
$Vote=$_POST['Vote'];

$var=mysql_query("INSERT INTO Athy (ID,Station,Sname,Fname,Address1,Address2,Address3,Address4,Vote,Division) VALUES ('$ID','$Station','$Sname','$Fname','$Address1','$Address2','Athy','Co Kildare','$Vote','$Division')")or die("unable to insert data");

if($var == 1){

	echo "Success";

}else
{

	echo "failed";
}
}else{
?> 
<html>
<body>
<form name="test.php" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  <p><img src="untitled.jpg" alt="" width="994" height="176" /></p>
  <p align="left">Id Number:
    <input type="text" name="ID" value="<?php echo $ID; ?>">
</p>
  <p align="left">Station:    
    <select name="Station">
<option value="Athy Boys Nat. School - Room 01">Athy Boys Nat. School - Room 01</option>
<option value="Athy Boys Nat. School - Room 02">Athy Boys Nat. School - Room 02</option>
<option value="Athy Boys Nat. School - Room 03">Athy Boys Nat. School - Room 03</option>
<option value="Athy Boys Nat. School - Room 04">Athy Boys Nat. School - Room 04</option>
<option value="Athy Boys Nat. School - Room 05">Athy Boys Nat. School - Room 05</option>
<option value="Athy Boys Nat. School - Room 06">Athy Boys Nat. School - Room 06</option>
<option value="Athy Boys Nat. School - Room 07">Athy Boys Nat. School - Room 07</option>
<option value="Athy Boys Nat. School - Room 08">Athy Boys Nat. School - Room 08</option>
<option value="Saint Vincent's Hospital">Saint Vincent's Hospital</option>
<option value="Scoil Mhichil Naofa - Room 01">Scoil Mhichil Naofa - Room 01</option>
<option value="Scoil Mhichil Naofa - Room 02">Scoil Mhichil Naofa - Room 02</option>
<option value="Scoil Mhichil Naofa - Room 03">Scoil Mhichil Naofa - Room 03</option>
<option value="Scoil Mhichil Naofa - Room 04">Scoil Mhichil Naofa - Room 04</option>
<option value="Scoil Mhichil Naofa - Room 05">Scoil Mhichil Naofa - Room 05</option>
</select>
  <p align="left">
    Firstname: 
    <input type="text" name="Fname" value="<?php echo $Fname; ?>"> 
  </p>
  <p align="left">Lastname: 
    <input type="text" name="Sname" value="<?php echo $Sname; ?>">
  </p>
    <p align="left">
    Address 1: 
    <input type="text" name="Address1" value="<?php echo $Address1; ?>">
  </p>
  <p align="left">Address 2:
   <select name="Address2">
<option value="Ardreigh, (ED Athy Rural)">Ardreigh, (ED Athy Rural)</option>
<option value="Ardreigh, (Inside U.D.)">Ardreigh, (Inside U.D.)</option>
<option value="Ardrew">Ardrew</option>
<option value="Ardrew Halting Site">Ardrew Halting Site</option>
<option value="Ashville">Ashville</option>
<option value="Athmore Apartments, Church Road">Athmore Apartments, Church Road</option>
<option value="Aughaboura">Aughaboura</option>
<option value="AB8">Avondale Drive</option>
<option value="SVH">Ballybought</option>
<option value="SMN1">Ballynascullogue</option>
<option value="SMN2">Banta Na Bearú</option>
<option value="SMN3">Barkersford</option>
<option value="SNM4">Barrack Lane</option>
<option value="SNM5">Barrow Quay</option>
<option value="AB1">Barrowford</option>
<option value="AB2">Beech Grove</option>
<option value="AB3">Belview</option>
<option value="AB4">Bennettsbridge, (ED Athy Rural)</option>
<option value="AB5">Bennettsbridge, (ED A Rur UD)</option>
<option value="AB6">Blackparks, (ED A Rural UD)</option>
<option value="AB7">Blackparks, (ED Athy W Urb)</option>
<option value="AB8">Bleach (Bungalows)</option>
<option value="SVH">Bleach (Two Storey)</option>
<option value="SMN1">Bothar Bui</option>
<option value="SMN2">Bradburys Flats, Leinster Street</option>
<option value="SMN3">Branswood, (01-50)</option>
<option value="SNM4">Branswood, (051-100)</option>
<option value="SNM5">Branswood, (101-150)</option>
<option value="AB1">Branswood, (151-200)</option>
<option value="AB2">Bray Lower</option>
<option value="AB3">Bray Upper</option>
<option value="AB4">Bridgefield Manor</option>
<option value="AB5">Burrows (The), Coneyburrow</option>
<option value="AB6">Butlers Lane</option>
<option value="AB7">Canal Close</option>
<option value="AB8">Canal Side</option>
<option value="SVH">Canal Walk</option>
<option value="SMN1">Carberry Park</option>
<option value="SMN2">Cardington, (ED A Rural UD)</option>
<option value="SMN3">Cardington, (ED Athy Rural)</option>
<option value="SNM4">Cardington Court</option>
<option value="SNM5">Cardington Demesne, (ED A Rural UD)</option>
<option value="AB1">Cardington Demesne, (ED Athy Rural)</option>
<option value="AB2">Carlow Road</option>
<option value="AB3">Castle Park, (01-50)</option>
<option value="AB4">Castle Park, (51-100)</option>
<option value="AB5">Chanterlands, (Athy Rural)</option>
<option value="AB6">Chanterlands, (Athy East Urb)</option>
<option value="AB7">Chapel Hill</option>
<option value="AB8">Church Crescent</option>
<option value="SVH">Church Road</option>
<option value="SMN1">Clonmullin, (01-50)</option>
<option value="SMN2">Clonmullin, (051-100)</option>
<option value="SMN3">Clonmullin, (101-150)</option>
<option value="SNM4">Clonmullin Retirement Village</option>
<option value="SNM5">Cloverlodge Nursing Home</option>
<option value="AB1">Cluain Bearú</option>
<option value="AB2">Cois Bhearú, Ard Bhearú</option>
<option value="AB3">Cois Bhearú, Bearú Mhór</option>
<option value="AB4">Cois Bhearú, Cluan Bhearú</option>
<option value="AB5">Cois Bhearú, Gleann Bhearú</option>
<option value="AB6">Cois Bhearú, Rathstewart</option>
<option value="AB7">Cois Bhearú, Slí Bhearú</option>
<option value="AB8">Coney Avenue, Coneyburrow</option>
<option value="SVH">Coney Drive, Coneyburrow</option>
<option value="SMN1">Coney Green, Coneyburrow</option>
<option value="SMN2">Coney Meadows, Coneyburrow, (051-100)</option>
<option value="SMN3">Coney Meadows, Coneyburrow, (101-150)</option>
<option value="SNM4">Coney Meadows, Coneyburrow, (001-50)</option>
<option value="SNM5">Coney Park, Coneyburrow</option>
<option value="AB1">Coney Walk, Coneyburrow</option>
<option value="AB2">Coneyburrow</option>
<option value="AB3">Coneyburrow Housing Scheme</option>
<option value="AB4">Convent Gardens, Monasterevin Road</option>
<option value="AB5">Convent Lane</option>
<option value="AB6">Convent View</option>
<option value="AB7">Coolroe</option>
<option value="AB8">Corrán Ard, Kilkenny Road, (01-50)</option>
<option value="SVH">Corrán Ard, Kilkenny Road, (051-100)</option>
<option value="SMN1">Corrán Ard, Kilkenny Road, (101-150)</option>
<option value="SMN2">Courtown East</option>
<option value="SMN3">Courtown West</option>
<option value="SNM4">Cuan Mhuire, Cardington,</option>
<option value="SNM5">Dominican Church Road Apartments</option>
<option value="AB1">Dominican Priory</option>
<option value="AB2">Dublin Road</option>
<option value="AB3">Duke Street</option>
<option value="AB4">Dun Brinn, Ardreigh Field</option>
<option value="AB5">Dun Brinn, Ardreigh Walk</option>
<option value="AB6">Dun Brinn, Ardrew Court</option>
<option value="AB7">Dun Brinn, Ardrew Fields</option>
<option value="AB8">Dun Brinn, Ardrew Heights</option>
<option value="SVH">Dun Brinn, Ardrew Walk</option>
<option value="SMN1">Dun Brinn, Barrow View</option>
<option value="SMN2">Dun Brinn, Barrow Way</option>
<option value="SMN3">Dun Brinn, Bleach Road</option>
<option value="SNM4">Dun Brinn, Bridgeview Gardens</option>
<option value="SNM5">Dun Brinn, Fortbarrington Drive</option>
<option value="AB1">Dun Brinn, River View</option>
<option value="AB2">Dun Brinn, Sunnyside Lawns</option>
<option value="AB3">Dun na Ri, Coneyburrow</option>
<option value="AB4">Earls Court</option>
<option value="AB5">Edmond Rice Square</option>
<option value="AB6">Emily Row</option>
<option value="AB7">Emily Square</option>
<option value="AB8">Fairfield Apartments, Dublin Road</option>
<option value="SVH">Flinters Close</option>
<option value="SMN1">Flinters Place</option>
<option value="SMN2">Forest</option>
<option value="SMN3">Forest Park</option>
<option value="SNM4">Foxhill</option>
<option value="SNM5">Gallow Hill Court, Kildare Road</option>
<option value="AB1">Gallowshill, (ED Athy Rural)</option>
<option value="AB2">Gallowshill, (ED A Rur UD)</option>
<option value="AB3">Geraldine, (ED Athy Rur UD)</option>
<option value="AB4">Geraldine, (ED Athy Rural)</option>
<option value="AB5">Geraldine Road</option>
<option value="AB6">Goulyduff</option>
<option value="AB7">Graysland, (ED Athy E Urb)</option>
<option value="AB8">Graysland, (ED Athy Rur UD)</option>
<option value="SVH">Greenhills</option>
<option value="SMN1">Holmcroft</option>
<option value="SMN2">Janeville Place</option>
<option value="SMN3">Kilcoo</option>
<option value="SNM4">Kildare Road</option>
<option value="SNM5">Kingsgrove</option>
<option value="AB1">Kingsgrove, Graysland</option>
<option value="AB2">Leinster Court</option>
<option value="AB3">Leinster Street</option>
<option value="AB4">Malone Place</option>
<option value="AB5">Mansfield Grove</option>
<option value="AB6">Marina Court, (01-50)</option>
<option value="AB7">Marina Court, (51-100)</option>
<option value="AB8">McAuley Court, St Vincents Hospital</option>
<option value="SVH">McDonnell Drive</option>
<option value="SMN1">Meeting Lane</option>
<option value="SMN2">Michael Dooley Terrace</option>
<option value="SMN3">Milltown</option>
<option value="SNM4">Minch Terrace</option>
<option value="SNM5">Mount Offaly</option>
<option value="AB1">Nelson Street</option>
<option value="AB2">Oaklawn</option>
<option value="AB3">Offaly Street</option>
<option value="AB4">Orchard (The), Dublin Road</option>
<option value="AB5">Orchard (The), Kildare Road</option>
<option value="AB6">Pairc Bhride, (01-50)</option>
<option value="AB7">Pairc Bhride, (51-100)</option>
<option value="AB8">Park Avenue</option>
<option value="SVH">Paudeenourstown, (ED Athy E Urb)</option>
<option value="SMN1">Paudeenourstown, (ED Athy Rur UD)</option>
<option value="SMN2">Plewmans Terrace</option>
<option value="SMN3">Preston Gate</option>
<option value="SNM4">Priory Court</option>
<option value="SNM5">Prussellstown</option>
<option value="AB1">Prussellstown Green, The Way</option>
<option value="AB2">Prussellstown Housing Scheme</option>
<option value="AB3">Quarry</option>
<option value="AB4">Rathstewart</option>
<option value="AB5">Rathstewart Crescent, (051-100)</option>
<option value="AB6">Rathstewart Crescent, (01-50)</option>
<option value="AB7">Rheban Avenue</option>
<option value="AB8">Rheban Castle</option>
<option value="SVH">Rheban Manor, (051-100)</option>
<option value="SMN1">Rheban Manor, (01-50)</option>
<option value="SMN2">Rheban Manor, Cyprian Avenue</option>
<option value="SMN3">Rheban Manor, Hollands (The)</option>
<option value="SNM4">Rheban Manor, Hollands Avenue</option>
<option value="SNM5">Rheban Manor, Hollands Park</option>
<option value="AB1">Rheban Manor, Moneen Drive</option>
<option value="AB2">Rheban Manor, Moneen View</option>
<option value="AB3">Riverdale Apartments</option>
<option value="AB4">Riversdale</option>
<option value="AB5">Rockfield Road</option>
<option value="AB6">Rosbran</option>
<option value="AB7">Roundhills</option>
<option value="AB8">Russellstown</option>
<option value="SVH">Saint Dominics Park</option>
<option value="SMN1">Saint Johns Lane</option>
<option value="SMN2">Saint Johns Manor</option>
<option value="SMN3">Saint Josephs Terrace Lower</option>
<option value="SNM4">Saint Josephs Terrace Upper</option>
<option value="SNM5">Saint Martins Terrace</option>
<option value="AB1">Saint Michaels Court</option>
<option value="AB2">Saint Michaels Terrace</option>
<option value="AB3">Saint Patricks Avenue</option>
<option value="AB4">Saint Vincents Hospital</option>
<option value="AB5">Saint Vincents Hospital Extern</option>
<option value="AB6">Salisbury</option>
<option value="AB7">Sawyerswood</option>
<option value="AB8">Shackleton Court</option>
<option value="SVH">Shamrock Drive</option>
<option value="SMN1">Shamrocklodge</option>
<option value="SMN2">Shanrath</option>
<option value="SMN3">Shanrath East</option>
<option value="SNM4">Shanrath Rise</option>
<option value="SNM5">Shanrath West, (ED Athy Rur UD)</option>
<option value="AB1">Shanrath West, (ED Athy Rural)</option>
<option value="AB2">Shrewleen Lane</option>
<option value="AB3">Srowland</option>
<option value="AB4">Stanhope Place</option>
<option value="AB5">Stanhope Street</option>
<option value="AB6">The Moat, Castlefields</option>
<option value="AB7">Tomard, (ED Athy E Urb)</option>
<option value="AB8">Tomard, (ED Athy Rural)</option>
<option value="SVH">Tomard, (ED Athy Rur UD)</option>
<option value="SMN1">Tonlegee</option>
<option value="SMN2">Tonlegee Court</option>
<option value="SMN3">Tonlegee Downs</option>
<option value="SNM4">Tonlegee Lawns</option>
<option value="SNM5">Townparks, (ED Athy W Urb)</option>
<option value="AB1">Townparks, (ED Athy E Urb)</option>
<option value="AB2">Townparks, (ED Athy Rur UD)</option>
<option value="AB3">Townparks, (ED Athy Rural)</option>
<option value="AB4">Townparks Housing Scheme</option>
<option value="AB5">Tullygorey</option>
<option value="AB6">Whitecastle Lawn, (51-100)</option>
<option value="AB7">Whitecastle Lawn, (01-50)</option>
<option value="AB8">William Street</option>
<option value="SVH">William Street Upper</option>
<option value="SMN1">Willsgrove</option>
<option value="SMN2">Woodstock Close</option>
<option value="SMN3">Woodstock North, (ED Athy Rural)</option>
<option value="SNM4">Woodstock North, (ED Athy Rur UD)</option>
<option value="SNM5">Woodstock South, (ED Athy Rur UD)</option>
<option value="SMN1">Woodstock South, (ED Athy Rural)</option>
<option value="SMN2">Woodstock South, (ED Athy W Urb)</option>
<option value="SMN3">Woodstock Street,</option>
</select>
  </p>
  <p align="left">Division: 
   <select name="Division">
<option value="Athy East Urban">Athy East Urban</option>
<option value="Athy Rural">Athy Rural</option>
<option value="Athy Rural (Inside U. D.)">Athy Rural (Inside U. D.)</option>
<option value="Athy West Urban">Athy West Urban</option>
</select>
  </p>
  <p align="left">Vote: 
   <select name="Vote">
<option value="Unknown">Unknown</option>
<option value="Dail, European Parliament and Local Elections only">Dail, European Parliament and Local Elections only</option>
<option value="European Parliament and Local Elections only">European Parliament and Local Elections only</option>
<option value="Local Elections only">Local Elections only</option>
<option value="Post or special arrangement only">Post or special arrangement only</option>
</select>
  </p>
  <p align="left">
    <input type="submit" />
  </p>
</form>
</body>
</html>
<?
}
// don't forget to close the mysql connection
mysql_close();
?>  

 

 

Any help would be great!

Link to comment
https://forums.phpfreaks.com/topic/148982-solved-alligning-textboxes/
Share on other sites

I recently found an excellent way to do this via CSS.  This is an example of how to do it

 


<style type="text/css">
label {
width:150px;
margin-right:5px;
text-align:right;
display:block;
float:left;
}
</style>
<body>

<form>
<label for="item1">
<input type="text" id="item1" name="item1">
<br>
<label for="item2">
<input type="text" id="item2" name="item2">
</form>
</body>

How do I apply it to my code?

 

Instead of e.g.

 

<p align="left">Id Number:
    <input type="text" name="ID" value="<?php echo $ID; ?>">
</p>

 

try

 

<label for="ID">Id Number:</label>
<input type="text" name="ID" id="ID" value="<?php echo $ID; ?>" />

 

and remember to put the CSS

 

<style type="text/css">
label {
width:150px;
margin-right:5px;
text-align:right;
display:block;
float:left;
}
</style>

 

inside a pair of head (HTML) tags. They come after the html opening tag and before the body opening tag.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.