Maybe I don't understand what you're trying to accomplish -- and I'm not
sure what you meant by "parsed through then just one line" -- but the
application you have at the link would work if you set the default values
of the form elements to the data currently in your table.  Even if you have
a separate page for entering data, you can have the same script handle both
the data viewing and updating.

Hope that helps (but I'm guessing it won't)


> [Original Message]
> From: Robert Sossomon <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Date: 06/03/2004 11:23:31 PM
> Subject: Re: [PHP] Bulk table updates
>
> I use a separate page to do the addition of information to my DB
> currently, the whole set of information is being re-written as I type
> this, but where I am stuck is getting the whole thing to be parsed through
> then just one line.
>
> The code I currently use is as follows:
> <SNIP CODE>
> <!-- modifycart.php -->
>
>
> $get_Quote = "select st.id, st.sel_item_id, st.sel_item_desc,
> st.sel_item_price, st.sel_item_qty, st.sel_item_comment from
> store_shoppertrack as st left join items as si on si.id = st.sel_item_id
> where session_id = '$PHPSESSID' order by $vsort";
>
> $get_Quote_res = mysql_query($get_Quote) or die(mysql_error());
>
> while ($row = MYSQL_FETCH_ROW($get_Quote_res))
> $number = mysql_numrows($get_Quote_res);
>
>
> if (mysql_num_rows($get_Quote_res) < 1)
>  { //print message
>   $display_block = "<P>You have no items in your Quote. Please <a
> href=\"seestore.php\">continue to shop</a>!</P>";
>  }
> else
>  { //get info and build Quote display
>
>  while ($i < $number)
>   {
>    $id = mysql_result($get_Quote_res,$i,'id');
>    $item_title = mysql_result($get_Quote_res,$i,'sel_item_id');
>    $item_desc = mysql_result($get_Quote_res,$i,'sel_item_desc');
>    $item_price = mysql_result($get_Quote_res,$i,'sel_item_price');
>    $item_qty = mysql_result($get_Quote_res,$i,'sel_item_qty');
>    $item_comment = mysql_result($get_Quote_res,$i,'sel_item_comment');
>
>
>    if ($item_title == " >>>>>")
>    {
> $display_block .= "<tr><td>Comment:</td><td colspan=2 align=center><form
> method=post action=\"replacecart.php\"><input type=\"hidden\"
> name=\"sel_item_id\" value=\"$item_title\"><input type=\"text\" size=75
> name=\"sel_item_desc\" value=\"$item_desc\"><input type=\"hidden\"
> name=\"sel_item_qty\" value=\"1\"><input type=\"hidden\" name=\"SESSID\"
> value=\"$PHPSESSID\">\n<input type=\"hidden\" name=\"id\"
> value=\"$id\">\n<input type=\"hidden\" name=\"url\"
> value=\"$_SERVER[PHP_SELF]?view_code=$view_code\"><input type=\"hidden\"
> name=\"sel_item_price\" value=\"0\"></td><td><select
> name=\"color\"><option value=\"aqua\">aqua</option><option
> value=\"black\">black</option><option value=\"blue\">blue</option><option
> value=\"fuchsia\">fuchsia</option><option
> value=\"gray\">gray</option><option value=\"green\">green</option><option
> value=\"lime\">lime</option><option
> value=\"maroon\">maroon</option><option
> value=\"navy\">navy</option><option value=\"olive\">olive</option><option
> value=\"purple\">purple</option><option value=\"red\">red</option><option
> value=\"silver\">silver</option><option
> value=\"teal\">teal</option><option value=\"white\">white</option><option
> value=\"yellow\">yellow</option></select>\n</td><td>Currently:
> $item_comment</td><td><input type=\"submit\" name=\"submit\"
> value=\"Modify\"></form></td></tr>\n";   }
>    else
>    {
> $display_block .= "\n<tr><td><form method=post
> action=\"replacecart.php\">\n";
> $display_block .= "$item_title</td><td><input type=text size=4
> name=\"sel_item_qty\" value=\"$item_qty\">\n";
> $display_block .= "</td><td><input type=\"text\" size=75
> name=\"sel_item_desc\" value=\"$item_desc\">";
> $display_block .= "<input type=\"hidden\" name=\"SESSID\"
> value=\"$PHPSESSID\">\n<input type=\"hidden\" name=\"id\"
> value=\"$id\">\n<input type=\"hidden\" name=\"sel_item_id\"
> value=\"$item_title\">\n";
> $display_block .= "<input type=\"hidden\" name=\"url\"
> value=\"$_SERVER[PHP_SELF]?view_code=$view_code\">\n</td><td>";
> $display_block .= "<input type=\"text\" name=\"sel_item_price\" size=\"5\"
> value=\"$item_price\">\n</td><td>\n<input type=\"text\" name=\"comment\"
> value=\"$item_comment\"></td><td>\n";
> $display_block .= "<input type=\"submit\" name=\"submit\"
> value=\"Modify\"></form></td>\n";
>
>    }
>    $i++;
>    }
>
> <!-- End Modify Cart -->
>
> <!-- Replacecart.php -->
>
>    $addtocart = "replace into store_shoppertrack
>
values('$_POST[id]','$_POST[SESSID]','$_POST[sel_item_id]','$_POST[sel_item_
qty]','$_POST[sel_item_price]','$_POST[sel_item_desc]','$comment',
> now(),'','','','')";
>
>    mysql_query($addtocart);
>
> <!-- End Replace Cart -->
>
> <End Snip CODE>
>
> I have a test set of data and stuff set up on my server:
> http://lonewolf.homelinux.net/quoter
>
> There are some errors in not getting to other tables, but they are
> irrelevant for seeing what is there.  The data in the table is of course
> bogus data, but you should see what I am getting at.
>
> Thanks,
> Robert
>
>
> > Use a SELECT query to get the values (SELECT * FROM table) and a table
> > that has form input fields in the cells.  The values for the form fields
> > would be based on the array you get from the SELECT query.  The form
could
> > be something like <form action="<?=$PHP_SELF ?>" method="post">.  In the
> > script, before the body, you would have an if statement to check whether
> > the submit button for the form is set; if it is set, it will run an
INSERT
> > INTO query:
> >
> > if (isset ($submit)) {
> >     $query = "INSERT INTO . . . ";
> >     $query_result = @mysql_query ($query);
> > }
> >
> > If the form is submitted, then the values in all the form fields
> > (including any changes) will go into the database.  If it's not
submitted,
> > the current values will be displayed in the tabled-embedded form.
> > Actually, I think if the form is submitted, it will redisplay with the
new
> > values as defaults.
> >
> > Hopefully this will work, or lead you in the right direction.
> >
> >
> >
> > -----Original Message-----
> > From: Robert Sossomon <[EMAIL PROTECTED]>
> > Sent: Jun 3, 2004 6:23 PM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP] Bulk table updates
> >
> > I am looking for a tutorial or a already created class or file that I
can
> > use to learn how to create a form that is populated from a database
table
> > that can be edited in every row and column and takes only 1 SAVE button
to
> > upload all the changes.
> >
> > Thanks,
> > Robert
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to