Need help with submitting information into MySQL

wxdqz

New Member
Problems problems!

Ok, I can submit information into the database but when I press the "Edit" button to pull up the information to edit again, it just shows the name of the data and not the other information as well...... here is the code, I would appreciate any help, thank you...


<form action="countries.php" method="post">
<select name="country" size=5>

<?

if (isset($submit)){

$q = "SELECT * FROM tblCountries WHERE strCountryName = '$country'";

$r = mysql_fetch_array(mysql_db_query($db_name,$q));

print "Exists: " . $r["strCountryName"] . "<br>";


if ($r["strCountryName"] != "") {

$q = "UPDATE tblCountries SET strCountryName='$country',strCountryName='$strCountryName', memCountryDescription='$memCountryDescription',memCountryRecap='$memCountryRecap',lngRegionID='$lngRegionID',

lngImageID='$lngImageID',lngDiscographyID='$lngDiscographyID',lngProgramSegmentID='$lngProgramSegmentID',intCountryDeleted='$intCountryDeleted',

dtmCountryLastModified='$dtmCountryLastModified',lngDataEntryID='$lngDataEntryID' WHERE strCountryName='$country'";



} else {



$q = "INSERT INTO tblCountries(strCountryName, memCountryDescription, memCountryRecap, lngRegionID, lngImageID, lngDiscographyID,lngProgramSegmentID,

intCountryDeleted,dtmCountryLastModified,lngDataEntryID) VALUES ('$country','$memCountryDescription','$memCountryRecap', '$lngRegionID' , '$lngImageID','$lngDiscographyID','$lngProgramSegmentID',

'$intCountryDeleted','$dtmCountryLastModified','$lngDataEntryID')";



}



print "<!--\n$q\n-->\n";



$ret = mysql_db_query($db_name,$q);



print "Result: " . mysql_affected_rows(). ": " . mysql_error() . "<br>";



} elseif (isset($purge)) {



mysql_db_query($db_name,"DELETE FROM tblCountries WHERE strCountryName ='$country'");



}



?>







<?



$q = "Select strCountryName FROM tblCountries ORDER BY strCountryname";



$res = mysql_db_query($db_name,$q);



if ($res) {



while ($r = mysql_fetch_array($res)) {



print "<option value=http://www.phpbuilder.com/board/archive/index.php/\"" . $r["strCountryName"] . "\">" . $r["strCountryName"] . "\n";



}



}



?>



</select>







<input type="submit" name="edit" value="Edit">



<input type="submit" name="purge" value="Delete">



</form>







<hr>



<form action="countries.php" method="post">



<?



if (isset($edit)){



$q = "SELECT*FROM tblCountries WHERE strCountryName ='$country'";



$res = mysql_db_query($db_name,$q);



if ($res) {



$w = mysql_fetch_array($res);



}



}



?>


<b>Country Name:</b><input type="text" name="country" value=http://www.phpbuilder.com/board/archive/index.php/"<? print $w["strCountryName"]; ?>"><br><br>

<b>Country Description:</b><br><textarea cols=50 rows=10><? print $w["memCountryDescription"]; ?></textarea><br>

<b>Country Keywords:</b><br><textarea cols=50 rows=13><? print $w["memCountryKeywords"]; ?> </textarea><br>

<b>Country Recap:</b><br><textarea cols=50 rows=10><? print $w["memCountryRecap"]; ?> </textarea><br><br>

<B>Regions:</B>

<SELECT NAME="Regions[]" SIZE=1>

<?

$q = "SELECT * FROM tblRegions";
$res = mysql_db_query($db_name, $q);
if ($res) {
while($r = mysql_fetch_array($res)) {
print "<option value=\"" . $r["lngRegionID"] . "\"";

if (isset($edit)) {
$q="SELECT lngRegionID from tblCountries where strCountryName ='$country'";
$res2 = mysql_db_query($db_name, $q);
if ($res2) {
while($x = mysql_fetch_array($res2)) {
if ($r["lngRegionID"] == $x["lngRegionID"]) {
print " SELECTED ";
}
}
}
}
print ">" . $r["strRegionName"] ."\n";
}
}

?>
</select>


<b>Images:</b>
<SELECT NAME="Images[]" SIZE=1>

<?

$q = "SELECT * FROM tblImages";
$res = mysql_db_query($db_name, $q);
if ($res) {
while($r = mysql_fetch_array($res)) {
print "<option value=http://www.phpbuilder.com/board/archive/index.php/\"" . $r["lngImageID"] . "\"";

if (isset($edit)) {
$q="SELECT lngImageID from tblCountries where strCountryName ='$country'";
$res2 = mysql_db_query($db_name, $q);
if ($res2) {
while($x = mysql_fetch_array($res2)) {
if ($r["lngImageID"] == $x["lngImageID"]) {
print " SELECTED ";
}
}
}
}
print ">" . $r["strImageCaption"] ."\n";
}
}

?>
</select>

<b>Discograhy:</b>
<SELECT NAME="Discography[]" SIZE=1>

<?

$q = "SELECT * FROM tblDiscographies";
$res = mysql_db_query($db_name, $q);
if ($res) {
while($r = mysql_fetch_array($res)) {
print "<option value=http://www.phpbuilder.com/board/archive/index.php/\"" . $r["lngDiscographyID"] . "\"";

if (isset($edit)) {
$q="SELECT lngDiscographyID from tblCountries where strCountryName ='$country'";
$res2 = mysql_db_query($db_name, $q);
if ($res2) {
while($x = mysql_fetch_array($res2)) {
if ($r["lngDiscographyID"] == $x["lngDiscographyID"]) {
print " SELECTED ";
}
}
}
}
print ">" . $r["strDiscographyName"] ."\n";
}
}

?>
</select>


<b>Program Segments:</b>
<SELECT NAME="ProgramSegments[]" SIZE=1>

<?

$q = "SELECT * FROM tblProgramSegments";
$res = mysql_db_query($db_name, $q);
if ($res) {
while($r = mysql_fetch_array($res)) {
print "<option value=http://www.phpbuilder.com/board/archive/index.php/\"" . $r["lngProgramSegmentID"] . "\"";

if (isset($edit)) {
$q="SELECT lngProgramSegmentID from tblCountries where strCountryName ='$country'";
$res2 = mysql_db_query($db_name, $q);
if ($res2) {
while($x = mysql_fetch_array($res2)) {
if ($r["lngProgramSegmentID"] == $x["lngProgramSegmentID"]) {
print " SELECTED ";
}
}
}
}
print ">" . $r["lngProgramSegmentID"] ."\n";
}
}

?>
</select>

<b>Deleted:</b><input type="checkbox" value=http://www.phpbuilder.com/board/archive/index.php/"<? print $w["intCountryDeleted"]; ?>"><br><br>

<b>Last Modified:</b><input type="text" value="<? print $w["dtmCountryLastModified"]; ?>">

<b>Data Entry ID:</b>
<SELECT NAME="DataEntry[]" SIZE=1>

<?

$q = "SELECT * FROM tblDataEntry";
$res = mysql_db_query($db_name, $q);
if ($res) {
while($r = mysql_fetch_array($res)) {
print "<option value=\"" . $r["lngDataEntryID"] . "\"";

if (isset($edit)) {
$q="SELECT lngDataEntryID from tblCountries where strCountryName ='$country'";
$res2 = mysql_db_query($db_name, $q);
if ($res2) {
while($x = mysql_fetch_array($res2)) {
if ($r["lngDataEntryID"] == $x["lngDataEntryID"]) {
print " SELECTED ";
}
}
}
}
print ">" . $r["strDataEntryFirstName"] ."\n";
}
}

?>
</select>


<br><br>


<input type="submit" name="submit" value=http://www.phpbuilder.com/board/archive/index.php/submit>



</form>


</body>
 
Back
Top