mikebyrne Posted March 16, 2009 Share Posted March 16, 2009 Im trying to get values returned from my DB based on the users selected option on my form ie If my user selects Ardreigh, (ED Athy Rural) ($Address2) the First name ($Fname) and Surname ($Sname) of eveyone with that address will be displayed 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("Select `Fname`,`Sname`FROM `Athy` WHERE `Address2`='".$Address2."'" )or die("No Data"); if (mysql_num_rows > 0) { while ($row = mysql_fetch_assoc($var)) { echo $row['Fname'].' '.$row['Sname']; } } 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"><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"> <input type="submit" /> </p> </form> </body> </html> <? } // don't forget to close the mysql connection mysql_close(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/149651-solved-no-values-being-returned-from-db/ Share on other sites More sharing options...
pkSML Posted March 16, 2009 Share Posted March 16, 2009 First thing: make sure your input data in sanitized! You're using raw POST data, which can lead to security issues. See the php manual on mysql_real_escape_string. So you're getting duplicate results for any address entered. Here's a 'hack' way to do it: if (mysql_num_rows($var) > 0) { // any further processing here // use mysql_fetch_array in a while loop to get each } Quote Link to comment https://forums.phpfreaks.com/topic/149651-solved-no-values-being-returned-from-db/#findComment-785841 Share on other sites More sharing options...
Kalland Posted March 16, 2009 Share Posted March 16, 2009 Hi, You're not submitting the form correctly i think: Try changing this: <input type="submit" /> Into the following: <input name="submit" value="Submit" type="submit" /> And add another if statement checking whether or not the submit button has been pressed before checking if the fields are filled in or not. Quote Link to comment https://forums.phpfreaks.com/topic/149651-solved-no-values-being-returned-from-db/#findComment-785844 Share on other sites More sharing options...
mikebyrne Posted March 16, 2009 Author Share Posted March 16, 2009 I've changed the submit button but still no joy. I'm a noob so and clear help would be great Quote Link to comment https://forums.phpfreaks.com/topic/149651-solved-no-values-being-returned-from-db/#findComment-785962 Share on other sites More sharing options...
Maq Posted March 16, 2009 Share Posted March 16, 2009 ie If my user selects Ardreigh, (ED Athy Rural) ($Address2) the First name ($Fname) and Surname ($Sname) of eveyone with that address will be displayed You know the POST will get the "value" of the select statement not the text inside it... Your code was a little messed up: Try: $sql = "Select `Fname`,`Sname`FROM `Athy` WHERE `Address2`='".$Address2."'"; echo $sql; $var = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($var) > 0) { while ($row = mysql_fetch_assoc($var)) { echo $row['Fname'].' '.$row['Sname']; } } else { echo "Failed"; } } Quote Link to comment https://forums.phpfreaks.com/topic/149651-solved-no-values-being-returned-from-db/#findComment-785977 Share on other sites More sharing options...
mikebyrne Posted March 16, 2009 Author Share Posted March 16, 2009 No im still getting no data displayed my code now looks like <? 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']; $sql = "Select `Fname`,`Sname`FROM `Athy` WHERE `Address2`='".$Address2."'"; echo $sql; $var = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($var) > 0) { while ($row = mysql_fetch_assoc($var)) { echo $row['Fname'].' '.$row['Sname']; } } 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"><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"> <input name="submit" value="Submit" type="submit" /> </p> </form> </body> </html> <? } // don't forget to close the mysql connection mysql_close(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/149651-solved-no-values-being-returned-from-db/#findComment-785991 Share on other sites More sharing options...
Maq Posted March 16, 2009 Share Posted March 16, 2009 And where does $_POST['ID'] come from? Quote Link to comment https://forums.phpfreaks.com/topic/149651-solved-no-values-being-returned-from-db/#findComment-785993 Share on other sites More sharing options...
mikebyrne Posted March 16, 2009 Author Share Posted March 16, 2009 Ah crap! The $ID was used in the previous form! I did a copy and paste job from that working code and tried to change it around for this one The only variable being posted is $Address2 while 'Fname' and 'Sname' are being retrivied from the DB How can I edit the first IF statement?? Quote Link to comment https://forums.phpfreaks.com/topic/149651-solved-no-values-being-returned-from-db/#findComment-785999 Share on other sites More sharing options...
syed Posted March 16, 2009 Share Posted March 16, 2009 Check that your form is submitting the variables. print_r($_POST); Quote Link to comment https://forums.phpfreaks.com/topic/149651-solved-no-values-being-returned-from-db/#findComment-786002 Share on other sites More sharing options...
Maq Posted March 16, 2009 Share Posted March 16, 2009 How can I edit the first IF statement?? Change it to Address2? if(!empty($_POST['Address2'])) { $Address2 = $_POST['Address2']; Quote Link to comment https://forums.phpfreaks.com/topic/149651-solved-no-values-being-returned-from-db/#findComment-786005 Share on other sites More sharing options...
mikebyrne Posted March 16, 2009 Author Share Posted March 16, 2009 Thats done it! Thanks One quick question. How do i get each name on a new line instead on next to each other all on the one line? Quote Link to comment https://forums.phpfreaks.com/topic/149651-solved-no-values-being-returned-from-db/#findComment-786024 Share on other sites More sharing options...
Maq Posted March 16, 2009 Share Posted March 16, 2009 echo $row['Fname'].' '.$row['Sname'] . ' '; Quote Link to comment https://forums.phpfreaks.com/topic/149651-solved-no-values-being-returned-from-db/#findComment-786032 Share on other sites More sharing options...
mikebyrne Posted March 16, 2009 Author Share Posted March 16, 2009 Thats great! Thanks for all your help Quote Link to comment https://forums.phpfreaks.com/topic/149651-solved-no-values-being-returned-from-db/#findComment-786034 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.