Jump to content

roland

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

roland's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [quote name='bugmuncher' date='Apr 7 2006, 04:10 AM' post='362463'] Hello, all. I believe I am a newbie. In the following example, I'm trying to get 2 text fields out of my database, just to see what they are (and hopefully to use them! I figured I would use mysql_fetch_assoc to make an array of pairs of orgName and orgSuggestedCopy. But when I run the script, instead of getting whole records, I get "m" for both echos. I think I am approaching this the wrong way. -------------------- $query="SELECT orgName, orgSuggestedCopy FROM organizations WHERE oid='$firstSub'"; $result=mysql_query($query) or die ("Error"); $debug="mysql_fetch_assoc($result)"; echo $debug['orgName']; echo $debug['orgSuggestedCopy']; [/quote] Try this... $query="SELECT orgName, orgSuggestedCopy FROM organizations WHERE oid='$firstSub'"; $result=mysql_query($query, $link) or die ("Error"); while($debug="mysql_fetch_assoc($result)){ echo $debug['orgName']; echo $debug['orgSuggestedCopy']; } [/quote]
  2. Anybody could help me! I retrieved data from my database table and print them inside the form then I want them to edit. Could anybody give a script on how to update a multiple rows... I have 500 rows with 5 fields in my database table I retrieved them all and output them inside the form so that I can edit them immediately. On the left in each row i put checked box so that i can check which row i want to edit. Let say I checked 5 rows from row 200: row 200 i changed field 4 and 5 row 201 i changed field 1 and 2 etc. How can i process these??? please help me!!! Here is waht I did: UPDATE book SET title="", author="", edition="", callnumber="" WHERE id=""; I know it will not work. Here is my output data inside the form: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] print "<form method=\"post\" action=\"insertResult2.php\">"; print "<table width=\"934\" border=\"0\" cellspacing=\"8\" class=\"texxt\" align=\"center\">"; print "<tr>"; print "<td bgcolor=\"#FFFFFF\"><strong>ID</strong></td>"; print "<td bgcolor=\"#FFFFFF\"><strong>&nbsp;</strong></td>"; print "<td bgcolor=\"#FFFFFF\"><strong>Authors</strong></td>"; print "<td bgcolor=\"#FFFFFF\"><strong>Titles</strong></td>"; print "<td bgcolor=\"#FFFFFF\"><strong>Editors</strong></td>"; print "<td bgcolor=\"#FFFFFF\"><strong>Call No.</strong></td>"; print "<td bgcolor=\"#FFFFFF\"><strong>Edition</strong></td>"; print "<td bgcolor=\"#FFFFFF\"><strong>Year</strong></td>"; print "<td bgcolor=\"#FFFFFF\"><strong>Notes</strong></td>"; print "</tr>"; $color_a = "#CCCCCC"; $color_b = "#8B8B8B"; include "../../HTML/Inc/connect.inc"; $query = "SELECT id, author1, title, callnumber, editions, year, notes FROM book WHERE author1 = 'Webster'"; $result = mysql_query($query,$link) or die("Cannot read record: ".mysql_error()); while($i++ <= mysql_num_rows($result) && $rs = mysql_fetch_array($result)) { $id[$i]=$rs['id']; $authors[$i]=$rs['author1']; $title[$i]=$rs['title']; $callnumber[$i]=$rs['callnumber']; $editions[$i]=$rs['editions']; $year[$i]=$rs['year']; $notes[$i]=$rs['notes']; $mod = ($i % 2); print "<tr>"; print "<td bgcolor=\""; if($mod == 0){echo $color_a;}else {echo $color_b;} print "\">$i</td>"; print "<td bgcolor=\""; if($mod == 0){echo $color_a;}else {echo $color_b;} print "\"><input type=\"checkbox\" name=\"box$i\" value=\"$id[$i]\"></td>"; print "<td bgcolor=\""; if($mod == 0){echo $color_a;}else {echo $color_b;} print "\"><textarea name=\"authors$i\" cols=\"8\">$authors[$i]</textarea></td>"; print "<td bgcolor=\""; if($mod == 0){echo $color_a;}else {echo $color_b;} print "\"><textarea name=\"title$i\">$title[$i]</textarea></td>"; print "<td bgcolor=\""; if($mod == 0){echo $color_a;}else {echo $color_b;} print "\"><input size=\"5\" type=\"text\" name=\"editors$i\" value=\"$editors[$i]\"></td>"; print "<td bgcolor=\""; if($mod == 0){echo $color_a;}else {echo $color_b;} print "\"><input type=\"text\" name=\"callnumber$i\" value=\"$callnumber[$i]\"></td>"; print "<td bgcolor=\""; if($mod == 0){echo $color_a;}else {echo $color_b;} print "\"><input size=\"5\" type=\"text\" name=\"editions$i\" value=\"$editions[$i]\"></td>"; print "<td bgcolor=\""; if($mod == 0){echo $color_a;}else {echo $color_b;} print "\"><input size=\"2\" type=\"text\" name=\"year$i\" value=\"$year[$i]\"></td>"; print "<td bgcolor=\""; if($mod == 0){echo $color_a;}else {echo $color_b;} print "\"><input type=\"text\" name=\"notes$i\" value=\"$notes[$i]\"></td>"; print "</tr>"; }//End While print "<tr>"; print "<td bgcolor=\""; if($mod == 0){echo $color_a;}else {echo $color_b;} print "\">&nbsp;</td>"; print "<td bgcolor=\""; if($mod == 0){echo $color_a;}else {echo $color_b;} print "\">&nbsp;</td>"; print "<td bgcolor=\""; if($mod == 0){echo $color_a;}else {echo $color_b;} print "\">&nbsp;</td>"; print "<td bgcolor=\""; if($mod == 0){echo $color_a;}else {echo $color_b;} print "\">&nbsp;</td>"; print "<td bgcolor=\""; if($mod == 0){echo $color_a;}else {echo $color_b;} print "\">&nbsp;</td>"; print "<td bgcolor=\""; if($mod == 0){echo $color_a;}else {echo $color_b;} print "\">&nbsp;</td>"; print "<td bgcolor=\""; if($mod == 0){echo $color_a;}else {echo $color_b;} print "\">&nbsp;</td>"; print "<td bgcolor=\""; if($mod == 0){echo $color_a;}else {echo $color_b;} print "\">&nbsp;</td>"; print "<td bgcolor=\""; if($mod == 0){echo $color_a;}else {echo $color_b;} print "\"><input type=\"Submit\" value=\"Update!\"></td>"; print "<input type=\"hidden\" name=\"edit_book\" value=\"book_record\">"; print "</tr>"; print "</table>"; print "</form>"; [/quote]
×
×
  • 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.