can anyone help me? please...

  • echa
  • Born
  • Born
  • echa
  • Posts: 1

Post 3+ Months Ago

hi,im having problem in updating mySQL.i was using wampserver and dreamweaver CS4. hope anyone can help me. Please :cry:

im want to update my data but its not working.
Here is the updatePublication coding.

 
$pubID_rsUpdatePublication = "-1";
if (isset($_GET['pubID'])) {
  $pubID_rsUpdatePublication = $_GET['pubID'];
}
mysql_select_db($database_myJournal, $myJournal);
$query_rsUpdatePublication = sprintf("SELECT * FROM author, publication WHERE author.PublicationID=publication.PublicationID AND publication.PublicationID=%s", GetSQLValueString($pubID_rsUpdatePublication, "int"));
$rsUpdatePublication = mysql_query($query_rsUpdatePublication, $myJournal) or die(mysql_error());
$row_rsUpdatePublication = mysql_fetch_assoc($rsUpdatePublication);
$totalRows_rsUpdatePublication = mysql_num_rows($rsUpdatePublication);
?>
function addElement() {
  var ni = document.getElementById('myDiv');
  var numi = document.getElementById('totalAuthor');
  var num = (document.getElementById('totalAuthor').value -1)+ 2;
  numi.value = num;
  var newdiv = document.createElement('div');
  var divIdName = 'my'+num+'Div';
  newdiv.setAttribute('id',divIdName);
  newdiv.innerHTML = '<input type="text" name="author'+num+'" id="author'+num+'" /><a style="cursor:pointer;color:blue;" onclick="this.parentNode.parentNode.removeChild(this.parentNode);">Remove Field</a>';
  //newdiv.innerHTML = '<input type="text" name="author'+num+'" id="author'+num+'" /><input value="Remove Author" onclick="removeElement('+divIdName+')" type="button">';
  //newdiv.innerHTML = 'Element Number '+num+' h
  as been added! <a href=\'#\' onclick=\'removeElement('+divIdName+')\'>Remove the div "'+divIdName+'"</a>';
  ni.appendChild(newdiv);
 
  //pass total author(s) value
  //document.form1.count.value = num;
}
function removeElement(divNum) {
  var d = document.getElementById('myDiv');
  var olddiv = document.getElementById(divNum);
  d.removeChild(olddiv);
  //olddiv.parentNode.getElementById(olddiv);
}
</script>
</head>
 
<body>
<form id="form1" name="form1" method="POST" action="insertForm.php">
  <p>
    <label>Faculty
      <select name="faculty" id="faculty">
        <option selected="selected" value="" <?php if (!(strcmp("", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Select</option>
        <option value="Faculty of Applied Sciences" <?php if (!(strcmp("Faculty of Applied Sciences", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Applied Sciences</option>
        <option value="Faculty of Information Technology and Quantitative Sciences" <?php if (!(strcmp("Faculty of Information Technology and Quantitative Sciences", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Information Technology and Quantitative Sciences</option>
        <option value="Faculty of Architecture, Planning and Surveying" <?php if (!(strcmp("Faculty of Architecture, Planning and Surveying", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Architecture, Planning and Surveying</option>
        <option value="Faculty of Sports Science and Recreation" <?php if (!(strcmp("Faculty of Sports Science and Recreation", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Sports Science and Recreation</option>
        <option value="Faculty of Medicine" <?php if (!(strcmp("Faculty of Medicine", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Medicine</option>
        <option value="Faculty of Health Sciences" <?php if (!(strcmp("Faculty of Health Sciences", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Health Sciences</option>
        <option value="Faculty of Pharmacy" <?php if (!(strcmp("Faculty of Pharmacy", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Pharmacy</option>
        <option value="Faculty of Dentistry" <?php if (!(strcmp("Faculty of Dentistry", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Dentistry</option>
        <option value="Faculty of Chemical Engineering" <?php if (!(strcmp("Faculty of Chemical Engineering", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Chemical Engineering</option>
        <option value="Faculty of Civil Engineering" <?php if (!(strcmp("Faculty of Civil Engineering", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Civil Engineering</option>
        <option value="Faculty of Electrical Engineering" <?php if (!(strcmp("Faculty of Electrical Engineering", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Electrical Engineering</option>
        <option value="Faculty of Mechanical Engineering" <?php if (!(strcmp("Faculty of Mechanical Engineering", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Mechanical Engineering</option>
        <option value="Faculty of Law" <?php if (!(strcmp("Faculty of Law", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Law</option>
        <option value="Faculty of Administrative Science and Policy Studies" <?php if (!(strcmp("Faculty of Administrative Science and Policy Studies", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Administrative Science and Policy Studies</option>
        <option value="Faculty of Communication and Media Studies" <?php if (!(strcmp("Faculty of Communication and Media Studies", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Communication and Media Studies</option>
        <option value="Faculty of Art and Design" <?php if (!(strcmp("Faculty of Art and Design", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Art and Design</option>
        <option value="Faculty of Education" <?php if (!(strcmp("Faculty of Education", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Education</option>
        <option value="Faculty of Artistic and Creative Technology" <?php if (!(strcmp("Faculty of Artistic and Creative Technology", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Artistic and Creative Technology</option>
        <option value="Faculty of Music" <?php if (!(strcmp("Faculty of Music", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Music</option>
        <option value="Faculty of Accountancy" <?php if (!(strcmp("Faculty of Accountancy", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Accountancy</option>
        <option value="Faculty of Business Management" <?php if (!(strcmp("Faculty of Business Management", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Business Management</option>
        <option value="Faculty of Hotel and Tourism Management" <?php if (!(strcmp("Faculty of Hotel and Tourism Management", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Hotel and Tourism Management</option>
        <option value="Faculty of Information Management" <?php if (!(strcmp("Faculty of Information Management", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Information Management</option>
<option value="Faculty of Office Management and Technology" <?php if (!(strcmp("Faculty of Office Management and Technology", $row_rsUpdatePublication['faculty']))) {echo "selected=\"selected\"";} ?>>Faculty of Office Management and Technology</option>
      </select>
    </label>
  </p>
  <p>
    <label>Journal
      <select name="Journal" size="1" id="Journal">
        <option selected="selected" value="" <?php if (!(strcmp("", $row_rsUpdatePublication['JournalName']))) {echo "selected=\"selected\"";} ?>>Select</option>
        <option value="Economic Bulletin" <?php if (!(strcmp("Economic Bulletin", $row_rsUpdatePublication['JournalName']))) {echo "selected=\"selected\"";} ?>>Economic Bulletin</option>
        <option value="Journal of International Business and Entrepreneurship" <?php if (!(strcmp("Journal of International Business and Entrepreneurship", $row_rsUpdatePublication['JournalName']))) {echo "selected=\"selected\"";} ?>>Journal of International Business and Entrepreneurship</option>
        <option value="Journal of Sport and Recreation(JOSPOREC)" <?php if (!(strcmp("Journal of Sport and Recreation(JOSPOREC)", $row_rsUpdatePublication['JournalName']))) {echo "selected=\"selected\"";} ?>>Journal of Sport and Recreation(JOSPOREC)</option>
<option value="Malaysian Accounting Review" <?php if (!(strcmp("Malaysian Accounting Review", $row_rsUpdatePublication['JournalName']))) {echo "selected=\"selected\"";} ?>>Malaysian Accounting Review</option>
      </select>
    </label>
    <label>Volume
      <select name="volume" id="volume">
        <option value="" <?php if (!(strcmp("", $row_rsUpdatePublication['Volume']))) {echo "selected=\"selected\"";} ?>>Select</option>
        <option value="1" <?php if (!(strcmp(1, $row_rsUpdatePublication['Volume']))) {echo "selected=\"selected\"";} ?>>1</option>
        <option value="2" <?php if (!(strcmp(2, $row_rsUpdatePublication['Volume']))) {echo "selected=\"selected\"";} ?>>2</option>
        <option value="3" <?php if (!(strcmp(3, $row_rsUpdatePublication['Volume']))) {echo "selected=\"selected\"";} ?>>3</option>
        <option value="4" <?php if (!(strcmp(4, $row_rsUpdatePublication['Volume']))) {echo "selected=\"selected\"";} ?>>4</option>
        <option value="5" <?php if (!(strcmp(5, $row_rsUpdatePublication['Volume']))) {echo "selected=\"selected\"";} ?>>5</option>
        <option value="6" <?php if (!(strcmp(6, $row_rsUpdatePublication['Volume']))) {echo "selected=\"selected\"";} ?>>6</option>
        <option value="7" <?php if (!(strcmp(7, $row_rsUpdatePublication['Volume']))) {echo "selected=\"selected\"";} ?>>7</option>
        <option value="8" <?php if (!(strcmp(8, $row_rsUpdatePublication['Volume']))) {echo "selected=\"selected\"";} ?>>8</option>
        <option value="9" <?php if (!(strcmp(9, $row_rsUpdatePublication['Volume']))) {echo "selected=\"selected\"";} ?>>9</option>
<option value="10" <?php if (!(strcmp(10, $row_rsUpdatePublication['Volume']))) {echo "selected=\"selected\"";} ?>>10</option>
      </select>
    </label>
    <label>Year
      <select name="year" id="year">
        <option value="" <?php if (!(strcmp("", $row_rsUpdatePublication['PublicationYear']))) {echo "selected=\"selected\"";} ?>>Select</option>
        <option value="2009" <?php if (!(strcmp(2009, $row_rsUpdatePublication['PublicationYear']))) {echo "selected=\"selected\"";} ?>>2009</option>
        <option value="2008" <?php if (!(strcmp(2008, $row_rsUpdatePublication['PublicationYear']))) {echo "selected=\"selected\"";} ?>>2008</option>
        <option value="2007" <?php if (!(strcmp(2007, $row_rsUpdatePublication['PublicationYear']))) {echo "selected=\"selected\"";} ?>>2007</option>
        <option value="2006" <?php if (!(strcmp(2006, $row_rsUpdatePublication['PublicationYear']))) {echo "selected=\"selected\"";} ?>>2006</option>
        <option value="2005" <?php if (!(strcmp(2005, $row_rsUpdatePublication['PublicationYear']))) {echo "selected=\"selected\"";} ?>>2005</option>
        <option value="2004" <?php if (!(strcmp(2004, $row_rsUpdatePublication['PublicationYear']))) {echo "selected=\"selected\"";} ?>>2004</option>
        <option value="2003" <?php if (!(strcmp(2003, $row_rsUpdatePublication['PublicationYear']))) {echo "selected=\"selected\"";} ?>>2003</option>
        <option value="2002" <?php if (!(strcmp(2002, $row_rsUpdatePublication['PublicationYear']))) {echo "selected=\"selected\"";} ?>>2002</option>
        <option value="2001" <?php if (!(strcmp(2001, $row_rsUpdatePublication['PublicationYear']))) {echo "selected=\"selected\"";} ?>>2001</option>
<option value="2000" <?php if (!(strcmp(2000, $row_rsUpdatePublication['PublicationYear']))) {echo "selected=\"selected\"";} ?>>2000</option>
      </select>
    </label>
  </p>
  <p>
    <label>Article
      <textarea name="article" cols="50" rows="2" id="article"><?php echo $row_rsUpdatePublication['Article']; ?></textarea>
    </label>
    <br />
  </p>
  <p>
  <label>Author</label><br />
      <?php do { ?>
        <input name="author1" type="text" id="author1" value="<?php echo $row_rsUpdatePublication['FullName']; ?>" />
      <a href="updateAuthor.php?AuthorID=<?php echo $row_rsUpdatePublication['AuthorID']; ?>">Edit Author</a><br />
        <?php } while ($row_rsUpdatePublication = mysql_fetch_assoc($rsUpdatePublication)); ?>
      <span id="myDiv"> </span>  
    <!--<input type="button" value="Add Author" onclick="addElement()"  />
   
    <input type="hidden" value="<?php //echo $row_rsUpdatePublication['totalAuthor']; ?>" id="totalAuthor" name="totalAuthor" />
    -->
 </form>
</body>
</html>
<?php
mysql_free_result($rsUpdatePublication);
?>[/code]


and here is where i update the author.

}
$colname_rsAuthor = "-1";
if (isset($_GET['AuthorID'])) {
  $colname_rsAuthor = $_GET['AuthorID'];
}
mysql_select_db($database_myJournal, $myJournal);
$query_rsAuthor = sprintf("SELECT * FROM author WHERE AuthorID = %s", GetSQLValueString($colname_rsAuthor, "int"));
$rsAuthor = mysql_query($query_rsAuthor, $myJournal) or die(mysql_error());
$row_rsAuthor = mysql_fetch_assoc($rsAuthor);
$totalRows_rsAuthor = mysql_num_rows($rsAuthor);
 
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
 
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "formEditAuthor")) {
  $updateSQL = sprintf("UPDATE author SET StafNo=%s, MatrikNo=%s, FullName=%s, comments=%s WHERE AuthorID=%s",
                       GetSQLValueString($_POST['stafNo'], "int"),
                       GetSQLValueString($_POST['matrikNo'], "int"),
                       GetSQLValueString($_POST['fullName'], "text"),
                       GetSQLValueString($_POST['comments'], "text"),
                       GetSQLValueString($_POST['AuthorID'], "int"));
 
  mysql_select_db($database_myJournal, $myJournal);
  $Result1 = mysql_query($updateSQL, $myJournal) or die(mysql_error());
 
  $updateGoTo = "updateAuthor.php?stat=success";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
 
 
<body>
<?php if ($_GET['stat']!='success'&&$_GET['']=='') { ?>
<form id="formEditAuthor" name="formEditAuthor" method="POST" action="<?php echo $editFormAction; ?>">
<input type="hidden" name="AuthorID" id="AuthorID" value="" />
  <p>
    <label>Author
      <input name="fullName" type="text" id="fullName" value="<?php echo $row_rsAuthor['FullName']; ?>" />
    </label>
  </p>
  <p>
    <label> Staff Number
      <input name="stafNo" type="text" id="stafNo" value="<?php echo $row_rsAuthor['StafNo']; ?>" />
    </label>
  </p>
  <p>
    <label>Matrik Number
      <input name="matrikNo" type="text" id="matrikNo" value="<?php echo $row_rsAuthor['MatrikNo']; ?>" />
    </label>
  </p>
  <p>
    <label>Comments
      <textarea name="comments" id="comments"><?php echo $row_rsAuthor['comments']; ?></textarea>
    </label>
  </p>
  <p>
    <label>
      <input type="submit" name="btnUpdate" id="btnUpdate" value="Update" />
    </label>
    <label>
      <input type="reset" name="btnReset" id="button" value="Reset" />
    </label>
  </p>
  <input type="hidden" name="MM_update" value="formEditAuthor" />
</form>
<?php } ?>
<?php if ($_GET['stat']=='success') { ?>
  You have successfully update the author information.
  <?php } ?>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($rsAuthor);
?>[/code]


help me to update both. i have try but nothing works.
Moderator Remark: Edited to show the coding from post text clearer.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 55 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.