Re: Using arrays to take records from a html table and update database
Well, it would have been if the email addy was correct...
"PSI_Orion" <orion@psiss.co mwrote in message
news:mexyg.3457 $v4.1602@newsfe 3-win.ntli.net...
Well, it would have been if the email addy was correct...
"PSI_Orion" <orion@psiss.co mwrote in message
news:mexyg.3457 $v4.1602@newsfe 3-win.ntli.net...
File sent.
>
"Ian Davies" <iandan.dav@vir gin.netwrote in message
news:Q0oyg.5782 5$ST2.5343@news fe5-win.ntli.net...
>
>
>
"Ian Davies" <iandan.dav@vir gin.netwrote in message
news:Q0oyg.5782 5$ST2.5343@news fe5-win.ntli.net...
>Cheers.
>that would be great
>Ian
>>
>"PSI_Orion" <orion@psiss.co mwrote in message
>news:vnbyg.470 47$1g.3775@news fe1-win.ntli.net...
>changes
>be
>be
>more
>the
>to
>try
>in
>modify
>using
>to
>width:
>align="left">< b><u><?=$dataAr ray['title']?></u></b><p><u>Starrin g:</u><br><i
>d
>onmouseover="p opShow(this,img _<?=$recordCoun t?>,'infoLayer_ <?=$recordCount ?>
>onmouseover="p opShow(this,img _<?=$recordCoun t?>,'infoLayer_ <?=$recordCount ?>
>src='images/certs/".$certImag e[$dataArray['certificate']].".gif'><BR>".$ data
>so
>dropdown
>WHERE
>class="bodytex t"><input
>?>>
>************** *************** *************** *************** *
>>
>>
>that would be great
>Ian
>>
>"PSI_Orion" <orion@psiss.co mwrote in message
>news:vnbyg.470 47$1g.3775@news fe1-win.ntli.net...
>>OK. I think it's all done as your require. Let me know and then I'll
>>forward the code.
>>>
>>http://www.psiss.com/dummy
>>>
>>Chris
>>>
>>"Ian Davies" <iandan.dav@vir gin.netwrote in message
>>news:357yg.26 $WY2.16@newsfe3-gui.ntli.net...
>Yes thats exactly what I have so far. except I dont have an update
>check
>box, which I didnt include because I suspect some users would make
>>forward the code.
>>>
>>http://www.psiss.com/dummy
>>>
>>Chris
>>>
>>"Ian Davies" <iandan.dav@vir gin.netwrote in message
>>news:357yg.26 $WY2.16@newsfe3-gui.ntli.net...
>Yes thats exactly what I have so far. except I dont have an update
>check
>box, which I didnt include because I suspect some users would make
>to the comments and categories etc but would forget to tick the update
>check
>box. My solution was to update ALL the displayed records. this wouldnt
>check
>box. My solution was to update ALL the displayed records. this wouldnt
>a
>problem as there would only be about between 5 and 100 so not a big
>deal
>if
>some are updated despite no changes being made. Also I dont have the
>ID
>displayed (its meaninless to the user), its in a hidden field which I
>planned to use to reference the correct record from the database table
>>
>ian
>>
>"PSI_Orion" <orion@psiss.co mwrote in message
>news:aE4yg.684 33$sz1.47146@ne wsfe6-gui.ntli.net...
>>Take a look at http://www.psiss.com/dummy to see if I'm on the right
>lines.
>>Obviously it's not nicely formatted and the "Update" checkboxes would
>problem as there would only be about between 5 and 100 so not a big
>deal
>if
>some are updated despite no changes being made. Also I dont have the
>ID
>displayed (its meaninless to the user), its in a hidden field which I
>planned to use to reference the correct record from the database table
>>
>ian
>>
>"PSI_Orion" <orion@psiss.co mwrote in message
>news:aE4yg.684 33$sz1.47146@ne wsfe6-gui.ntli.net...
>>Take a look at http://www.psiss.com/dummy to see if I'm on the right
>lines.
>>Obviously it's not nicely formatted and the "Update" checkboxes would
>>hidden and automatically set on an onchange event in the fields.
>>Also,
>>it
>>doesn't actually do any changes right now as I need to work on that
>>Also,
>>it
>>doesn't actually do any changes right now as I need to work on that
>but
>>I wanted to make sure I'm on the right lines first. Just tick some
>>update
>>checkboxes, click submit and see if that's what you are after.
>>>
>>Chris
>>>
>>"Ian Davies" <iandan.dav@vir gin.netwrote in message
>>news:KL2yg.63 521$Z61.2758@ne wsfe4-win.ntli.net...
>'....and a hidden field to contain...'
>SHOULD READ
>'....and I also have a hidden field that contains...'
>>
>>
>ian
>>
>>
>"Ian Davies" <iandan.dav@vir gin.netwrote in message
>news:EJ2yg.635 20$Z61.54928@ne wsfe4-win.ntli.net...
>>Hello
>>That is correct. also comment is a textarea. and a hidden field to
>>contain
>>the index of each row to use to update the correct record in the
>subsequent
>>sql statement.
>>>
>>Is your solution somehow based on creating an array from each of
>>the
>>elements.
>>The solution i was trying to do was to get 4 arrays and somehow
>>use
>them
>in
>>a loop with an sql update. But Im lost as to how to create and use
>>I wanted to make sure I'm on the right lines first. Just tick some
>>update
>>checkboxes, click submit and see if that's what you are after.
>>>
>>Chris
>>>
>>"Ian Davies" <iandan.dav@vir gin.netwrote in message
>>news:KL2yg.63 521$Z61.2758@ne wsfe4-win.ntli.net...
>'....and a hidden field to contain...'
>SHOULD READ
>'....and I also have a hidden field that contains...'
>>
>>
>ian
>>
>>
>"Ian Davies" <iandan.dav@vir gin.netwrote in message
>news:EJ2yg.635 20$Z61.54928@ne wsfe4-win.ntli.net...
>>Hello
>>That is correct. also comment is a textarea. and a hidden field to
>>contain
>>the index of each row to use to update the correct record in the
>subsequent
>>sql statement.
>>>
>>Is your solution somehow based on creating an array from each of
>>the
>>elements.
>>The solution i was trying to do was to get 4 arrays and somehow
>>use
>them
>in
>>a loop with an sql update. But Im lost as to how to create and use
>>arrays appropriately
>>>
>>Cheers
>>Ian
>>also I greatly appreciate your assistance
>>>
>>>
>>"PSI_Orion" <orion@psiss.co mwrote in message
>>news:e71yg.46 974$1g.21477@ne wsfe1-win.ntli.net...
>I'm presuming comment is the textbox (or do you use textarea),
>category
>is
>the dropdown and share is the checkbox?
>>
>I'm working on a solution now so I'm hoping I have it right.
>>
>PSI_Orion
>>
>"Ian Davies" <iandan.dav@vir gin.netwrote in message
>news:Q9%xg.524 08$IU2.3744@new sfe2-win.ntli.net...
>Hi
>I am trying to amend three fields all one text and two integer
>In my original code you will see what I mean
>The values for the text field would come from a textarea in
>one
>column
>>of
>the table and the values for the two integer fields would come
>from
>a
>dropdown list and a tick box which are in the other columns.
>Ian
>>
>>
>"PSI_Orion" <orion@psiss.co mwrote in message
>news:MQSxg.143 4$v4.793@newsfe 3-win.ntli.net...
>>Yes, that explains it much better. Which field is it you are
>trying
>to
>>amend? Is it a simple yes/no type field? If so then you
>>need
>>>
>>Cheers
>>Ian
>>also I greatly appreciate your assistance
>>>
>>>
>>"PSI_Orion" <orion@psiss.co mwrote in message
>>news:e71yg.46 974$1g.21477@ne wsfe1-win.ntli.net...
>I'm presuming comment is the textbox (or do you use textarea),
>category
>is
>the dropdown and share is the checkbox?
>>
>I'm working on a solution now so I'm hoping I have it right.
>>
>PSI_Orion
>>
>"Ian Davies" <iandan.dav@vir gin.netwrote in message
>news:Q9%xg.524 08$IU2.3744@new sfe2-win.ntli.net...
>Hi
>I am trying to amend three fields all one text and two integer
>In my original code you will see what I mean
>The values for the text field would come from a textarea in
>one
>column
>>of
>the table and the values for the two integer fields would come
>from
>a
>dropdown list and a tick box which are in the other columns.
>Ian
>>
>>
>"PSI_Orion" <orion@psiss.co mwrote in message
>news:MQSxg.143 4$v4.793@newsfe 3-win.ntli.net...
>>Yes, that explains it much better. Which field is it you are
>trying
>to
>>amend? Is it a simple yes/no type field? If so then you
>>need
>>adjust
>>your query accordingly. I don't have time right now to
>>explain
>>fully
>>but
>if
>>you send me a personal email to orion at psiss dot com I will
>>your query accordingly. I don't have time right now to
>>explain
>>fully
>>but
>if
>>you send me a personal email to orion at psiss dot com I will
>>and
>>explain how I would approach it.
>>>
>>Regards
>>>
>>PSI_Orion
>>>
>>"Ian Davies" <iandan.dav@vir gin.netwrote in message
>>news:BwPxg.46 899$1g.19898@ne wsfe1-win.ntli.net...
>Thanks for the reply
>The problem Im having isnt creating a table with the
>records
>>explain how I would approach it.
>>>
>>Regards
>>>
>>PSI_Orion
>>>
>>"Ian Davies" <iandan.dav@vir gin.netwrote in message
>>news:BwPxg.46 899$1g.19898@ne wsfe1-win.ntli.net...
>Thanks for the reply
>The problem Im having isnt creating a table with the
>records
>it.
>That
>works fine. Im trying to find a way where the users can
>That
>works fine. Im trying to find a way where the users can
>the
>records
>in a table and they are all updated in one go. I thought
>records
>in a table and they are all updated in one go. I thought
>arrays
>would
>be the answer, but Im not that familiar with them. At the
>moment
>the
>users
>click a button at the begining of a row and that record is
>displated
>>on
>a
>new page where it can be updated. But this requires the
>user
>would
>be the answer, but Im not that familiar with them. At the
>moment
>the
>users
>click a button at the begining of a row and that record is
>displated
>>on
>a
>new page where it can be updated. But this requires the
>user
>click
>and
>update one record at a time. Whereas I wish them to make
>all
>the
>changes
>to
>all the records they want in the table and then on clicking
>a
>button
>some
>script would take each row in turn and update that row in
>te
>>database,
>it
>would then loop through all the rows in the table and
>update
>each
>accordingly
>>
>Hope this explains it better
>>
>Ian
>>
>"PSI_Orion" <orion@psiss.co mwrote in message
>news:uFIxg.628 41$sz1.6724@new sfe6-gui.ntli.net...
>>If I understand you correctly, the way I would do it is
>>the
>same
>way
>>I
>have
>>my DVD database. This is rather than have the name of the
>elements
>>as
>>"commindex[]" etc, actually place the table creation
>>inside
>your
>>while
>loop
>>and increment the naming field using the i variable you
>>use,
>ie:
>>"commindex[<?=$i?>]".
>>>
>>As an example of what I mean, here is an excerpt of my DVD
>database
>code
>>which you can view at "http:// mydvds . psiss . com"
>>>
>>------------------------------------------------------
>>if($allRecord s 0)
>>{
>> $recordCount = 0;
>> while($recordCo unt < $allRecords)
>> {
>> if(($recordCoun t / 2) % 2 == 1)
>> {
>>?>
>> <tr align="center" class="tr_even" >
>><?
>> }
>> else
>> {
>>?>
>> <tr align="center" class="tr_odd">
>><?
>> }
>> for($colCount = 0; $colCount < 2 && $recordCount <
>$allRecords;
>>$colCount++ )
>> {
>> $dataArray = mysql_fetch_arr ay($result);
>> $dataArray['starring'] =
>str_replace("\ r","<BR>",$data Array['starring']);
>> $dataArray['synopsis'] =
>str_replace("\ r","<BR>",$data Array['synopsis']);
>> $dataArray['duration'] =
>>date('H:i',st rtotime($dataAr ray['duration']));
>>?>
>> <td background="ima ges/barSilver.jpg"
>width="30"><?= ($recordCount
>>+
>>1)?></td>
>> <td width="4">  ;</td>
>> <td>
>> <div class="div_info " style="position : absolute;
>and
>update one record at a time. Whereas I wish them to make
>all
>the
>changes
>to
>all the records they want in the table and then on clicking
>a
>button
>some
>script would take each row in turn and update that row in
>te
>>database,
>it
>would then loop through all the rows in the table and
>update
>each
>accordingly
>>
>Hope this explains it better
>>
>Ian
>>
>"PSI_Orion" <orion@psiss.co mwrote in message
>news:uFIxg.628 41$sz1.6724@new sfe6-gui.ntli.net...
>>If I understand you correctly, the way I would do it is
>>the
>same
>way
>>I
>have
>>my DVD database. This is rather than have the name of the
>elements
>>as
>>"commindex[]" etc, actually place the table creation
>>inside
>your
>>while
>loop
>>and increment the naming field using the i variable you
>>use,
>ie:
>>"commindex[<?=$i?>]".
>>>
>>As an example of what I mean, here is an excerpt of my DVD
>database
>code
>>which you can view at "http:// mydvds . psiss . com"
>>>
>>------------------------------------------------------
>>if($allRecord s 0)
>>{
>> $recordCount = 0;
>> while($recordCo unt < $allRecords)
>> {
>> if(($recordCoun t / 2) % 2 == 1)
>> {
>>?>
>> <tr align="center" class="tr_even" >
>><?
>> }
>> else
>> {
>>?>
>> <tr align="center" class="tr_odd">
>><?
>> }
>> for($colCount = 0; $colCount < 2 && $recordCount <
>$allRecords;
>>$colCount++ )
>> {
>> $dataArray = mysql_fetch_arr ay($result);
>> $dataArray['starring'] =
>str_replace("\ r","<BR>",$data Array['starring']);
>> $dataArray['synopsis'] =
>str_replace("\ r","<BR>",$data Array['synopsis']);
>> $dataArray['duration'] =
>>date('H:i',st rtotime($dataAr ray['duration']));
>>?>
>> <td background="ima ges/barSilver.jpg"
>width="30"><?= ($recordCount
>>+
>>1)?></td>
>> <td width="4">  ;</td>
>> <td>
>> <div class="div_info " style="position : absolute;
>400px;
>>z-index: 1; visibility: hidden;"
>id="infoLayer_ <?=$recordCount ?>"
>>>
>>
>>
>>>
>>
>>
>>z-index: 1; visibility: hidden;"
>id="infoLayer_ <?=$recordCount ?>"
>>>
>>
>>
>>>
>>
>>
>>>
>>
>>>
>>>
>>>
>>>>>>><?=$data Array['starring']?></i></p><p><?=$dataAr ray['synopsis']?></p></
>>
>>>
>>>
>>>
>>>>>>><?=$data Array['starring']?></i></p><p><?=$dataAr ray['synopsis']?></p></
>i
>>v
>>>
>><?
>> if($dataArray['dvd_image'] == "None")
>> {
>>?>
>> <img id="img_<?=$rec ordCount?>" width="50" height="70"
>>src="images/dvds/none_small.jpg"
>>>
>>
>>
>>>
>>
>>
>>v
>>>
>><?
>> if($dataArray['dvd_image'] == "None")
>> {
>>?>
>> <img id="img_<?=$rec ordCount?>" width="50" height="70"
>>src="images/dvds/none_small.jpg"
>>>
>>
>>
>>>
>>
>>
>',img_<?=$reco rdCount?>.width
>>+ 5,5)"
>>onmouseout="p opHide('infoLay er_<?=$recordCo unt?>')">
>><?
>> }
>> else
>> {
>>?>
>> <img id="img_<?=$rec ordCount?>" width="50" height="70"
>>src="images/dvds/<?=$dataArray['dvd_image']?>"
>>>
>>
>>
>>>
>>
>>
>>+ 5,5)"
>>onmouseout="p opHide('infoLay er_<?=$recordCo unt?>')">
>><?
>> }
>> else
>> {
>>?>
>> <img id="img_<?=$rec ordCount?>" width="50" height="70"
>>src="images/dvds/<?=$dataArray['dvd_image']?>"
>>>
>>
>>
>>>
>>
>>
>',img_<?=$reco rdCount?>.width
>>+ 5,5)"
>>onmouseout="p opHide('infoLay er_<?=$recordCo unt?>')">
>><?
>> }
>> echo " <img
>>>
>>
>>
>>>
>>
>>
>>+ 5,5)"
>>onmouseout="p opHide('infoLay er_<?=$recordCo unt?>')">
>><?
>> }
>> echo " <img
>>>
>>
>>
>>>
>>
>>
>Array['title'];
>>?>
>> </td>
>> <td width="4">  ;</td>
>> <td><b>Released </b><br><?=$dataA rray['year']?><br>
>> <b>Duration</b><br><?=$dataA rray['duration']?><br>
>> <b>Rating</b><br><img alt="Rating:
>><?=$dataArr ay['rating']/2?>"
>>align="absmid dle"
>>src="images/ratings/pips<?=$dataArr ay['rating']?>.gif"></td>
>> <td width="4">  ;</td>
>><?
>> $recordCount++;
>> }
>>?>
>> </tr>
>><?
>> }
>>}
>>----------------------------------
>>>
>>>
>>"Ian Davies" <iandan.dav@vir gin.netwrote in message
>>news:j3wxg.10 67$u4.703@newsf e3-win.ntli.net...
>Hello
>Needing help with a suitable solution.
>I have extracted records into a table under three
>columns
>'category',
>'comment' and share (the category column also holds the
>index
>no
>>of
>the
>record in a hidden field)
>I wish the user to be able to edit the data in the
>table,
>>?>
>> </td>
>> <td width="4">  ;</td>
>> <td><b>Released </b><br><?=$dataA rray['year']?><br>
>> <b>Duration</b><br><?=$dataA rray['duration']?><br>
>> <b>Rating</b><br><img alt="Rating:
>><?=$dataArr ay['rating']/2?>"
>>align="absmid dle"
>>src="images/ratings/pips<?=$dataArr ay['rating']?>.gif"></td>
>> <td width="4">  ;</td>
>><?
>> $recordCount++;
>> }
>>?>
>> </tr>
>><?
>> }
>>}
>>----------------------------------
>>>
>>>
>>"Ian Davies" <iandan.dav@vir gin.netwrote in message
>>news:j3wxg.10 67$u4.703@newsf e3-win.ntli.net...
>Hello
>Needing help with a suitable solution.
>I have extracted records into a table under three
>columns
>'category',
>'comment' and share (the category column also holds the
>index
>no
>>of
>the
>record in a hidden field)
>I wish the user to be able to edit the data in the
>table,
>I
>>have
>extracted the records into hiddenfield, textareas,
>>have
>extracted the records into hiddenfield, textareas,
>list
>>and
>checkbox so that they can make changes.
>I named these elements as arrays and wish to run an sql
>to
>take
>>each
>row
>in
>turn (and any changes made) and update the mysql table.
>I
>did
>something
>similar with just one record but am stuck as to how I
>use
>the
>>arrays
>of
>a
>number of form elements together
>>
>My code for the table is below but I dont know how the
>script
>>should
>go
>when
>the form is submitted to add each row in turn
>Help greatly appreciated
>Ian
>>
>>
>************** *************** *************** *************** ***********
><form action="comment select.php" method="post"
>enctype="multi part/form-data"
>name="UpdateCo mments">
> <table width="100%" border="0" cellpadding="0"
>cellspacing="2 "
>bgcolor="#FFFF FF">
> <tr align="center" class="ListHead ing">
> <td width="20%" height="31">Cat egory</td>
> <td width="60%" height="31">Com ment</td>
> <td width="10%" height="31">Sha re</td>
> </tr>
> <tr class="BodyText ">
> <?php
>while($row =& mysql_fetch_arr ay($commentresu lts)) {
>extract($row );
>>
>if ($i%2) {
> $class = 'row1';
> echo "<TR bgcolor=\"#CCCC CC\">\n";
>>
>} else {
> $class = 'row2';
> echo "<TR bgcolor=\"white \">\n";
>}
>$i += 1;
>?>
> <td width="20%" align="left"
>class="bodytex t"><select
>name="catego ry[]" style="WIDTH: 90%">
><option value="<?php echo $row['TypeID']; ?>"><?php echo
>$row['typedesc'];
>?></option>
> <?php
>$commenttype = mysql_query("SE LECT * FROM commenttype
>>and
>checkbox so that they can make changes.
>I named these elements as arrays and wish to run an sql
>to
>take
>>each
>row
>in
>turn (and any changes made) and update the mysql table.
>I
>did
>something
>similar with just one record but am stuck as to how I
>use
>the
>>arrays
>of
>a
>number of form elements together
>>
>My code for the table is below but I dont know how the
>script
>>should
>go
>when
>the form is submitted to add each row in turn
>Help greatly appreciated
>Ian
>>
>>
>************** *************** *************** *************** ***********
><form action="comment select.php" method="post"
>enctype="multi part/form-data"
>name="UpdateCo mments">
> <table width="100%" border="0" cellpadding="0"
>cellspacing="2 "
>bgcolor="#FFFF FF">
> <tr align="center" class="ListHead ing">
> <td width="20%" height="31">Cat egory</td>
> <td width="60%" height="31">Com ment</td>
> <td width="10%" height="31">Sha re</td>
> </tr>
> <tr class="BodyText ">
> <?php
>while($row =& mysql_fetch_arr ay($commentresu lts)) {
>extract($row );
>>
>if ($i%2) {
> $class = 'row1';
> echo "<TR bgcolor=\"#CCCC CC\">\n";
>>
>} else {
> $class = 'row2';
> echo "<TR bgcolor=\"white \">\n";
>}
>$i += 1;
>?>
> <td width="20%" align="left"
>class="bodytex t"><select
>name="catego ry[]" style="WIDTH: 90%">
><option value="<?php echo $row['TypeID']; ?>"><?php echo
>$row['typedesc'];
>?></option>
> <?php
>$commenttype = mysql_query("SE LECT * FROM commenttype
>>username
>=
>'$username'" );
>if (!$commenttype) {
>exit('<p>Err or performing query: ' . mysql_error() .
>'</p>');
>}
>while($row1 =& mysql_fetch_arr ay($commenttype )) {
>extract($row1) ;
>?>
> <option value="<?php echo
>$row1['TypeID'];
>>?>"><?php
>echo
>$row1['typedesc']; ?><br>
> </option>
> <?php
>}
>?>
> </select>
> <input name="commindex[]" type="hidden"
>value="<?php
>echo
>$commindex;
>?>"></td>
> <td width="60%" align="left" class="bodytext ">
><textarea
>name="comm[]" rows="2" style="WIDTH: 99%"><?php echo
>$comment;
>?></textarea></td>
> <td width="10%" align="center"
>=
>'$username'" );
>if (!$commenttype) {
>exit('<p>Err or performing query: ' . mysql_error() .
>'</p>');
>}
>while($row1 =& mysql_fetch_arr ay($commenttype )) {
>extract($row1) ;
>?>
> <option value="<?php echo
>$row1['TypeID'];
>>?>"><?php
>echo
>$row1['typedesc']; ?><br>
> </option>
> <?php
>}
>?>
> </select>
> <input name="commindex[]" type="hidden"
>value="<?php
>echo
>$commindex;
>?>"></td>
> <td width="60%" align="left" class="bodytext ">
><textarea
>name="comm[]" rows="2" style="WIDTH: 99%"><?php echo
>$comment;
>?></textarea></td>
> <td width="10%" align="center"
>type="checkbox "
>name="avail[]" value="checkbox " <?php share($availabl e);
>name="avail[]" value="checkbox " <?php share($availabl e);
></td>
> </tr>
> <?php
>}
>?>
> </table>
></form>
>>
>>
> </tr>
> <?php
>}
>?>
> </table>
></form>
>>
>>
>>
>>
>>>
>>>
>>
>>
>>>
>>>
>>
>>
>>
>>
>>>
>>>
>>
>>
>>>
>>>
>>
>>
>>>
>>>
>>
>>>
>>>
>>
>>
>>>
>>>
>>
>>
>>
>>
>>>
>>>
>>
>>
>>>
>>>
>>
>>
>>>
>>>
>>
>
Comment