Web Design Forums

PHP

Have questions about PHP? Ask them here and our experts will assist you before you know it! You can also find help in the documentation at PHP.net.

PHP: Edit Multiple Items/Rows and Update Button



Site of the Month Nominations
ENTER YOUR SITE NOW!

Reply
 
LinkBack Thread Tools
Old March 2 '04, 02:48 PM (#1)
msmith29063 is offline
New Member!
 
msmith29063's Avatar
 
Join Date: March 2004
Posts: 17
msmith29063
PHP: Edit Multiple Items/Rows and Update Button

What is the best way to add the ability to edit the field called equipPrice for multiple records and click the Update button? Note the Update button is being used for deleting checked items as well. Thank you so much for any help/advice.

<?php

// Connect to database
...

// If the form was submitted, delete the items selected from the database
if ($_POST["deleted_items"]) {

$deleted_items = join(', ', $_POST["deleted_items"]);
$query1 = "DELETE FROM equipment WHERE $equipID IN ($deleted_items)";
$result1 = @mysql_query($query1);
header("Location: index.php");
}

// Build query to fetch items from database
$query2 = "SELECT * FROM equipment ORDER BY $sortOrder";

// Execute query
$result2 = @mysql_query($query2);

// If query was okay AND we have at least 1 item...
if ($result2 && @mysql_num_rows($result2) > 0) {

print "<form action=\"index.php\" method=\"post\" target=\"main\">\n";
print "<table border=\"0\" cellspacing=\"0\" cellpadding=\"8\">\n";

// For each item returned from query...
while($row2 = mysql_fetch_array($result2)) {

print "<tr bgcolor=\"$row_color\">\n";
print "<td align=\"center\" valign=\"middle\"><input type=\"checkbox\" name=\"deleted_items[]\" value=\"" . stripslashes($row2['equipID']) . "\"></td>\n";

...

print "<td class=\"tiny\" align=\"left\" valign=\"middle\" nowrap>$<input type=\"text\" name=\"equipPrice\" value=\"" . stripslashes($row2['equipPrice']) . "\" size=\"8\"></td>\n";
print "</tr>\n";
}

print "</table>\n";
print "<br>\n";
print "<input type=\"submit\" value=\"Update\">\n";
print "</form>\n";

} else {

...

// Close link to MySQL server
mysql_close($link);

?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

  Web Design Forums » Programming Help » PHP

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
User Infomation
Your Avatar

Site Of The Month

Ticket Cake
Ticket Cake

Ticket Cake is a drupal based event ticketing platform. It features that ability to browse events and share them.

Nominate Your Site Now!

Advertisement
WolfCMS.org

Latest Articles
- by RickM
- by bfsog

Advertisement

Partner Links



All times are GMT -4. The time now is 02:55 AM.


WebDesignForums.net is Copyright © 2010 RikeMedia.

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163