Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

php question: capturing data in a form for mysql update

Participant ,
Jun 14, 2007 Jun 14, 2007
I'm trying to update my database by building a form that links a city with surrounding towns. I want to enter the main town and the surrounding towns and then it updates all records that contain the main town. the code runs without errors, but the data i'm entering is not finding its way into the variables and doesn't update the database . . . all help appreciated.

<form id="form1" name="form1" method="get" action="demograph_updatep2.php">
<label><strong class="innerpageheading">Main town</strong>
<input name="maintown" type="text" id="maintown" />
</label>
<p><label><span class="results_13px">Nearby Town1</span>
<input name="nearbytown1" type="text" id="nearbytown1" />
</label>
</p>
<p>
<label><span class="results_13px">NearbyTown2</span>
<input name="nearbytown2" type="text" id="nearbytown2" />
</label>
</p>
<p>
<label><span class="results_13px">NearbyTown3</span>
<input name="nearbytown3" type="text" id="nearbytown3" />
</label>
</p>
<p>
<label><span class="results_13px">NearbyTown4</span>
<input name="nearbytown4" type="text" id="nearbytown4" />
</label>
</p>
<p>
<label>
<input type="submit" name="Submit" value="Update" />
</label>
</p>
</form>


<?php

// setting variables

$maincity = $_GET['maintown'];
$nearbycity1 = $_GET['nearbytown1'];
$nearbycity2 = $_GET['nearbytown2'];
$nearbycity3 = $_GET['nearbytown3'];
$nearbycity4 = $_GET['nearbytown4'];


mysql_connect (localhost,"");
mysql_select_db("") or die( "Unable to select database");
mysql_query("UPDATE physician
SET

physician_City2 = $nearbycity1
WHERE physician_City1 IN ($maincity)
");
mysql_close();
?>

<?php
mysql_connect (localhost,"");
mysql_select_db("") or die( "Unable to select database");
mysql_query("UPDATE physician
SET

physician_City2 = 'East Grand Rapids'
WHERE physician_City1 IN ('Grand Rapids')
");
mysql_close();
?>
TOPICS
Server side applications
254
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 14, 2007 Jun 14, 2007
LATEST
please ignore the last ten lines: ?>

<?php
mysql_connect (localhost,"");
mysql_select_db("") or die( "Unable to select database");
mysql_query("UPDATE physician
SET

physician_City2 = 'East Grand Rapids'
WHERE physician_City1 IN ('Grand Rapids')
");
mysql_close();
?>

i was using those to test the sql code
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines