Jump to content

mikebyrne

Members
  • Posts

    780
  • Joined

  • Last visited

Everything posted by mikebyrne

  1. Im getting the following error Parse error: parse error in C:\xampp\htdocs\select.php on line 32 My code is <?php 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("Select $ID, $Fname, $Sname, $Station, $Address1, $Address2, $Division, $Vote From Athy")or die("unable to insert data"); if($var == 1){ echo "Success"; }else { echo "failed"; } } //if the ID already does exist .. do you want to UPDATE it instead of INSERTing a new one ??? }else{ ?> <html> <style type="text/css"> label { width:150px; margin-right:5px; text-align:right; display:block; float:left; } .style1 {font-weight: bold} </style> <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"><span class="style1"> <label for "ID"> Id Number:</label> </span> <input type="text" name="ID" value="<?php echo $ID; ?>"> </p> <p align="left"><strong> <label for "Station">Station</label> <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> </strong> <p align="left"><label for "Firstname"><strong>Firstname</strong></label> <input type="text" name="Fname" value="<?php echo $Fname; ?>"> </p> <p align="left"><label for "Lastname"><strong>Lastname</strong></label> <input type="text" name="Sname" value="<?php echo $Sname; ?>"> </p> <p align="left"><label for "Address1"><strong>Address 1</strong></label> <input type="text" name="Address1" value="<?php echo $Address1; ?>"> </p> <p align="left"><label for "Address2"><strong>Address 2</strong></label> <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"><label for "Division"><strong>Division</strong></label> <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"><label for "Vote"><strong>Vote</strong></label> <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(); ?> Line 32 refers to }else{
  2. The fields are already in variables ie $id, $fname etc My problem is how do i put them into a select statement based on the user of the fields options?
  3. Im looking to create a form which will allow the user to create a "select" statement which will produce the desired results from the db My form looks like this but I'm not sure how to code the Select statement <?php 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']; //NOT SURE HOW TO CODE THIS?? $var=mysql_query("Select ???????? 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> <style type="text/css"> label { width:150px; margin-right:5px; text-align:right; display:block; float:left; } .style1 {font-weight: bold} </style> <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"><span class="style1"> <label for "ID"> Id Number:</label> </span> <input type="text" name="ID" value="<?php echo $ID; ?>"> </p> <p align="left"><strong> <label for "Station">Station</label> <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> </strong> <p align="left"><label for "Firstname"><strong>Firstname</strong></label> <input type="text" name="Fname" value="<?php echo $Fname; ?>"> </p> <p align="left"><label for "Lastname"><strong>Lastname</strong></label> <input type="text" name="Sname" value="<?php echo $Sname; ?>"> </p> <p align="left"><label for "Address1"><strong>Address 1</strong></label> <input type="text" name="Address1" value="<?php echo $Address1; ?>"> </p> <p align="left"><label for "Address2"><strong>Address 2</strong></label> <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"><label for "Division"><strong>Division</strong></label> <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"><label for "Vote"><strong>Vote</strong></label> <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
  4. Sorry! I thought you ment the 2nd IF statement The code now gives me a parse error on this line $if(mysql_num_rows == 0) { //if the ID already exists, do not insert the record
  5. If tried this $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){ $query = mysql_query("SELECT * FROM athy WHERE ID = {$ID}"); $if(mysql_num_rows > 0) { //then the ID already exists echo "Success"; } }else { echo "failed"; } But im getting a parse errror
  6. Thanks for the responce Where do I place this within my code?
  7. Im looking to code some validation for my "ID" field that checks if the value already exists in my db before it passes the values through. my current 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> <style type="text/css"> label { width:150px; margin-right:5px; text-align:right; display:block; float:left; } .style1 {font-weight: bold} </style> <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"><span class="style1"> <label for "ID"> Id Number:</label> </span> <input type="text" name="ID" value="<?php echo $ID; ?>"> </p> <p align="left"><strong> <label for "Station">Station</label> <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> </strong> <p align="left"><label for "Firstname"><strong>Firstname</strong></label> <input type="text" name="Fname" value="<?php echo $Fname; ?>"> </p> <p align="left"><label for "Lastname"><strong>Lastname</strong></label> <input type="text" name="Sname" value="<?php echo $Sname; ?>"> </p> <p align="left"><label for "Address1"><strong>Address 1</strong></label> <input type="text" name="Address1" value="<?php echo $Address1; ?>"> </p> <p align="left"><label for "Address2"><strong>Address 2</strong></label> <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"><label for "Division"><strong>Division</strong></label> <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"><label for "Vote"><strong>Vote</strong></label> <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(); ?>
  8. 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!
  9. Im looking into inserting the data collected on the form into my DB but I'm not sure the best way to go about it. I presume i need something like this with the "else" section the SQL Insert statement but im not sure how to code it (no validation needed yet) if (empty($_POST['field'])) { //fields not passed, so display the form // print HTML code to display form } else { //we are in post mode. Make sure you validate the fields //execute the SQL assuming all data is validated } My current form looks like this <? include("connect.php"); // now you are connected and can query the database ?> <html> <body> <form action="test.php" method="post"> <p><img src="untitled.jpg" alt="" width="994" height="176" /></p> <p>Id Number: <input type="text" name="ID" /> </p> <p>Station: <select name="Station"> <option value="AB1">Athy Boys Nat. School - Room 01</option> <option value="AB2">Athy Boys Nat. School - Room 02</option> <option value="AB3">Athy Boys Nat. School - Room 03</option> <option value="AB4">Athy Boys Nat. School - Room 04</option> <option value="AB5">Athy Boys Nat. School - Room 05</option> <option value="AB6">Athy Boys Nat. School - Room 06</option> <option value="AB7">Athy Boys Nat. School - Room 07</option> <option value="AB8">Athy Boys Nat. School - Room 08</option> <option value="SVH">Saint Vincent's Hospital, Athy</option> <option value="SMN1">Scoil Mhichil Naofa - Room 01</option> <option value="SMN2">Scoil Mhichil Naofa - Room 02</option> <option value="SMN3">Scoil Mhichil Naofa - Room 03</option> <option value="SNM4">Scoil Mhichil Naofa - Room 04</option> <option value="SNM5">Scoil Mhichil Naofa - Room 05</option> </select> <p> Firstname: <input type="text" name="Fname" /> </p> <p>Lastname: <input type="text" name="Sname" /> </p> <p> Address 1: <input type="text" name="Address1" /> </p> <p> <p>Address 2: <select name="Address2"> <option value="AB1">Ardreigh, (ED Athy Rural)</option> <option value="AB2">Ardreigh, (Inside U.D.)</option> <option value="AB3">Ardrew</option> <option value="AB4">Ardrew Halting Site</option> <option value="AB5">Ashville</option> <option value="AB6">Athmore Apartments, Church Road</option> <option value="AB7">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>Division: <select name="Division"> <option value="AEU">Athy East Urban</option> <option value="AR">Athy Rural</option> <option value="AR2">Athy Rural (Inside U. D.)</option> <option value="AWU">Athy West Urban</option> </select> </p> <p>Vote: <select name="Vote"> <option value="U">Unknown</option> <option value="D">Dail, European Parliament and Local Elections only</option> <option value="E">European Parliament and Local Elections only</option> <option value="L">Local Elections only</option> <option value="S">Post or special arrangement only</option> </select> </p> <p> <input type="submit" /> </p> </form> </body> </html> <? // don't forget to close the mysql connection mysql_close(); ?>
  10. When I click on my submit button I want all the data in the textboxes and option boxes to go into my DB I assume the command would be something like $sql="INSERT INTO Athy (Fname, Lname, ID) VALUES ('$_POST[firstname]','$_POST[lastname]','$_POST[iD]')"; Im just not sure how to modify my existing code to allow this my current code <? include("connect.php"); // now you are connected and can query the database ?> <html> <body> <form action="test.php" method="post"> <p><img src="untitled.jpg" alt="" width="994" height="176" /></p> <p>Id Number: <input type="text" name="ID" /> </p> <p>Station: <select name="Station"> <option value="AB1">Athy Boys Nat. School - Room 01</option> <option value="AB2">Athy Boys Nat. School - Room 02</option> <option value="AB3">Athy Boys Nat. School - Room 03</option> <option value="AB4">Athy Boys Nat. School - Room 04</option> <option value="AB5">Athy Boys Nat. School - Room 05</option> <option value="AB6">Athy Boys Nat. School - Room 06</option> <option value="AB7">Athy Boys Nat. School - Room 07</option> <option value="AB8">Athy Boys Nat. School - Room 08</option> <option value="SVH">Saint Vincent's Hospital, Athy</option> <option value="SMN1">Scoil Mhichil Naofa - Room 01</option> <option value="SMN2">Scoil Mhichil Naofa - Room 02</option> <option value="SMN3">Scoil Mhichil Naofa - Room 03</option> <option value="SNM4">Scoil Mhichil Naofa - Room 04</option> <option value="SNM5">Scoil Mhichil Naofa - Room 05</option> </select> <p> Firstname: <input type="text" name="Fname" /> </p> <p>Lastname: <input type="text" name="Sname" /> </p> <p> Address 1: <input type="text" name="Address1" /> </p> <p> Address 2: <input type="text" name="Address2" /> </p> <p>Division: <select name="Division"> <option value="AEU">Athy East Urban</option> <option value="AR">Athy Rural</option> <option value="AR2">Athy Rural (Inside U. D.)</option> <option value="AWU">Athy West Urban</option> </select> </p> <p>Vote: <select name="Vote"> <option value="U">Unknown</option> <option value="D">Dail, European Parliament and Local Elections only</option> <option value="E">European Parliament and Local Elections only</option> <option value="L">Local Elections only</option> <option value="S">Post or special arrangement only</option> </select> </p> <p> <input type="submit" /> </p> </form> </body> </html> <? //close the mysql connection mysql_close(); ?>
  11. I cant see whats wrong with the code??
  12. I'm trying to run a test page to input data into my DB test.php <html> <body> <? include("connect.php"); // now you are connected and can query the database <form action="test.php" method="post"> Firstname: <input type="text" name="Fname" /> Lastname: <input type="text" name="Sname" /> VOTE: <input type="text" name="vote" /> <input type="submit" /> </form> // don't forget to close the mysql connection mysql_close(); ?> </body> </html> Im getting the error Parse error: parse error in C:\xampp\htdocs\test.php on line 7 line 7 = <form action="test.php" method="post">
  13. I changed it to the following and got it to work <? include("connect.php"); // now you are connected and can query the database $result = mysql_query("SELECT * FROM athy"); while($row = mysql_fetch_array($result)) { echo $row['Fname'] . " " . $row['Sname']; echo "<br />"; } // don't forget to close the mysql connection mysql_close(); ?>
  14. I've written 2 php files to connect and run from the db I run my test.php file <? include("connect.php"); // now you are connected and can query the database $request = mysql_query("select * from athy"); // loop through the results with mysql_fetch_array() while($row = mysql_fetch_array($result)){ echo $row[0]." / ".$row[1]."<br>\n"; } // don't forget to close the mysql connection mysql_close(); ?> But im getting the error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\test.php on line 7 line 7 is while($row = mysql_fetch_array($result)){ Any idea what's wrong?
  15. I'm trying to create a simple php page to enter data to my database but im unsure where to start Im using xampp with mysql The SQL for the table im creating is CREATE TABLE `athy` ( `ID` decimal(10,0) NOT NULL, `Station` varchar(50) NOT NULL, `Sname` varchar(15) NOT NULL, `Fname` varchar(15) NOT NULL, `Address1` varchar(15) NOT NULL, `Address2` varchar(15) NOT NULL, `Address3` varchar(15) NOT NULL, `Address4` varchar(15) NOT NULL, `Vote` varchar(7) DEFAULT NULL, `Division` varchar(15) NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  16. I probably have to create an SQL statement as its the backend of the DB
  17. Im probably not making myslef clear (sorry!) Im setting up a DB and while im inputting the data I just want certain options in certain fields ie instead of manually typing either "Unknown, Dial, European, Post" i want a drop down menu to appear in the Vote field containing the above
  18. Sorry I'm using Navicat as a DB tool not frontend I'm looking at PHPMYADMIN now but im still not sure how to apply the options
  19. The SQL for my table is CREATE TABLE `athy` ( `ID` decimal(10,0) NOT NULL, `Station` varchar(50) NOT NULL, `Sname` varchar(15) NOT NULL, `Fname` varchar(15) NOT NULL, `Address1` varchar(15) NOT NULL, `Address2` varchar(15) NOT NULL, `Address3` varchar(15) NOT NULL, `Address4` varchar(15) NOT NULL, `Vote` varchar(7) DEFAULT NULL, `Division` varchar(15) NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; How would I apply the options to "vote"
  20. Yeah that's exactly what I need but I'm using Navicat as a front end so Im not sure how to apply it
  21. I am currently setting up a database and in one of the fields i want the user to only input one of 5 options (-,D,E,L,S) How do i format the field to allow these options in a drop down box? The field name is Vote with Varchar of length 5
  22. I know that the following code is used to prevent SQL Injections but what exactly does the trim do? Does it remove the spaces before and after the variable? $name = mysql_real_escape_string(trim($_POST['name']));
×
×
  • 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.