[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-general
Subject:    Re: [PHP] need help to update a mysql table from dynamic form
From:       Patrick Aljord <patcito () gmail ! com>
Date:       2006-02-05 16:05:33
Message-ID: 6b6419750602050805m7b8fb277i52c5e6d0aaaf1c92 () mail ! gmail ! com
[Download RAW message or body]

On 2/4/06, Sumeet <mailing@prateeksha.com> wrote:
> Patrick Aljord wrote:
> > could someone please help me on that one? http://hashphp.org/pastebin?pid=6156
> >
> > basically this is how I do:
> > I display a mysql table in an html table and I put each value in an
> > input text box.
> > At the bottom I put a submit button to update changes.
> > My question is how do I update everything knowing that I don't know in
> > advance the name of all the input textbox?
> >
> > Here is the code to display the table:
> >  <table width=\"1\" border=\"1\">
> >    <tbody>
> >      <tr>
> >        <td><strong>English</strong></td>
> >        <td><strong>Fran&#231;ais</strong></td>
> >        <td><strong>Espa&#241;ol</strong></td>
> >
> >      ";
> >  $getdisplaycatname = "select
> > catid,categoryfr,categoryen,categoryes,categoryar from category";
> >  $getdisplaycatnameq = mysql_query($getdisplaycatname);
> >  while ($getcatrow = mysql_fetch_array($getdisplaycatnameq)){
> >  //$display_category=mysql_result($getcatnameq, 0);
> >  $showcatid=$getcatrow['catid'];
> >  $showcat=$getcatrow['categoryfr'];
> >  $showcaten=$getcatrow['categoryen'];
> >  $showcates=$getcatrow['categoryes'];
> >  echo "  <tr>
> >        <td> <input type=\"text\" name=\"<????>\" value=\"$showcaten\"
> > size=\"18\"/></td>
> >        <td> <input type=\"text\" name=\"<????>\" value=\"$showcat\"
> > size=\"18\"/></td>
> >        <td> <input type=\"text\" name=\"<????>\" value=\"$showcates\"
> > size=\"18\"/></td>
> >      </tr>
> >   ";
> >  }
> >  echo "
> >  </tr>
> >    </tbody>
> >  </table>
> >  <br /><input type=\"submit\" name=\"update\"  value=\"update\" /></form>
> >
> >  ";
> >  thanx in advance
> >
> > Pat
> >
>
> not sure of exactly u r try to do...but i can suggest the following code.
>
> while ($getcatrow = mysql_fetch_array($getdisplaycatnameq)){
>
>    /* assuming getcatrow is an array like
>     getcatrow = array( "field1" => "value1",
>                        "field2" => "value2");
>
>   */
>
>    while( list($key,$value) = each($getcatrow) ) {
>         echo "<input type='text' name='$key' value='$value'
>  > size='18'/>";

Thanx a lot for your answer, but the problem is that for each $key I
have 3 column with the same id: categoryen, categoryfr and categoryes.
So that gives me three input type=text name=$key with the same $key
for the three categories then it goes to the next row. How can I make
the difference between the input text that have the same name when
updating?
see what I mean?

Thanx in advance
Pat

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic