Connecting Tech Pros Worldwide Help | Site Map

Using arrays to take records from a html table and update database

Ian Davies
Guest
 
Posts: n/a
#1: Jul 25 '06
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, so I have
extracted the records into hiddenfield, textareas, dropdown 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="commentselect.php" method="post" enctype="multipart/form-data"
name="UpdateComments">
<table width="100%" border="0" cellpadding="0" cellspacing="2"
bgcolor="#FFFFFF">
<tr align="center" class="ListHeading">
<td width="20%" height="31">Category</td>
<td width="60%" height="31">Comment</td>
<td width="10%" height="31">Share</td>
</tr>
<tr class="BodyText">
<?php
while($row =& mysql_fetch_array($commentresults)) {
extract($row);

if ($i%2) {
$class = 'row1';
echo "<TR bgcolor=\"#CCCCCC\">\n";

} else {
$class = 'row2';
echo "<TR bgcolor=\"white\">\n";
}
$i += 1;
?>
<td width="20%" align="left" class="bodytext"><select
name="category[]" style="WIDTH: 90%">
<option value="<?php echo $row['TypeID']; ?>"><?php echo $row['typedesc'];
?></option>
<?php
$commenttype = mysql_query("SELECT * FROM commenttype WHERE username =
'$username'");
if (!$commenttype) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
while($row1 =& mysql_fetch_array($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" class="bodytext"><input type="checkbox"
name="avail[]" value="checkbox" <?php share($available); ?> </td>
</tr>
<?php
}
?>
</table>
</form>

************************************************** **********


PSI_Orion
Guest
 
Posts: n/a
#2: Jul 26 '06

re: Using arrays to take records from a html table and update database


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($allRecords 0)
{
$recordCount = 0;
while($recordCount < $allRecords)
{
if(($recordCount / 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_array($result);
$dataArray['starring'] = str_replace("\r","<BR>",$dataArray['starring']);
$dataArray['synopsis'] = str_replace("\r","<BR>",$dataArray['synopsis']);
$dataArray['duration'] = date('H:i',strtotime($dataArray['duration']));
?>
<td background="images/barSilver.jpg" width="30"><?=($recordCount +
1)?></td>
<td width="4">&nbsp;</td>
<td>
<div class="div_info" style="position: absolute; width: 400px;
z-index: 1; visibility: hidden;" id="infoLayer_<?=$recordCount?>"
align="left"><b><u><?=$dataArray['title']?></u></b><p><u>Starring:</u><br><i><?=$dataArray['starring']?></i></p><p><?=$dataArray['synopsis']?></p></div>
<?
if($dataArray['dvd_image'] == "None")
{
?>
<img id="img_<?=$recordCount?>" width="50" height="70"
src="images/dvds/none_small.jpg"
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>',img_<?=$recordCount?>. width
+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
<?
}
else
{
?>
<img id="img_<?=$recordCount?>" width="50" height="70"
src="images/dvds/<?=$dataArray['dvd_image']?>"
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>',img_<?=$recordCount?>. width
+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
<?
}
echo " <img
src='images/certs/".$certImage[$dataArray['certificate']].".gif'><BR>".$dataArray['title'];
?>
</td>
<td width="4">&nbsp;</td>
<td><b>Released</b><br><?=$dataArray['year']?><br>
<b>Duration</b><br><?=$dataArray['duration']?><br>
<b>Rating</b><br><img alt="Rating: <?=$dataArray['rating']/2?>"
align="absmiddle"
src="images/ratings/pips<?=$dataArray['rating']?>.gif"></td>
<td width="4">&nbsp;</td>
<?
$recordCount++;
}
?>
</tr>
<?
}
}
----------------------------------


"Ian Davies" <iandan.dav@virgin.netwrote in message
news:j3wxg.1067$u4.703@newsfe3-win.ntli.net...
Quote:
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, so I have
extracted the records into hiddenfield, textareas, dropdown 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="commentselect.php" method="post"
enctype="multipart/form-data"
name="UpdateComments">
<table width="100%" border="0" cellpadding="0" cellspacing="2"
bgcolor="#FFFFFF">
<tr align="center" class="ListHeading">
<td width="20%" height="31">Category</td>
<td width="60%" height="31">Comment</td>
<td width="10%" height="31">Share</td>
</tr>
<tr class="BodyText">
<?php
while($row =& mysql_fetch_array($commentresults)) {
extract($row);
>
if ($i%2) {
$class = 'row1';
echo "<TR bgcolor=\"#CCCCCC\">\n";
>
} else {
$class = 'row2';
echo "<TR bgcolor=\"white\">\n";
}
$i += 1;
?>
<td width="20%" align="left" class="bodytext"><select
name="category[]" style="WIDTH: 90%">
<option value="<?php echo $row['TypeID']; ?>"><?php echo $row['typedesc'];
?></option>
<?php
$commenttype = mysql_query("SELECT * FROM commenttype WHERE username =
'$username'");
if (!$commenttype) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
while($row1 =& mysql_fetch_array($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" class="bodytext"><input
type="checkbox"
name="avail[]" value="checkbox" <?php share($available); ?> </td>
</tr>
<?php
}
?>
</table>
</form>
>
************************************************** **********
>
>

Ian Davies
Guest
 
Posts: n/a
#3: Jul 26 '06

re: Using arrays to take records from a html table and update database


Thanks for the reply
The problem Im having isnt creating a table with the records in it. That
works fine. Im trying to find a way where the users can modify the records
in a table and they are all updated in one go. I thought using 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 to 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.comwrote in message
news:uFIxg.62841$sz1.6724@newsfe6-gui.ntli.net...
Quote:
If I understand you correctly, the way I would do it is the same way I
have
Quote:
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
Quote:
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($allRecords 0)
{
$recordCount = 0;
while($recordCount < $allRecords)
{
if(($recordCount / 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_array($result);
$dataArray['starring'] =
str_replace("\r","<BR>",$dataArray['starring']);
Quote:
$dataArray['synopsis'] =
str_replace("\r","<BR>",$dataArray['synopsis']);
Quote:
$dataArray['duration'] = date('H:i',strtotime($dataArray['duration']));
?>
<td background="images/barSilver.jpg" width="30"><?=($recordCount +
1)?></td>
<td width="4">&nbsp;</td>
<td>
<div class="div_info" style="position: absolute; width: 400px;
z-index: 1; visibility: hidden;" id="infoLayer_<?=$recordCount?>"
>
align="left"><b><u><?=$dataArray['title']?></u></b><p><u>Starring:</u><br><i
Quote:
><?=$dataArray['starring']?></i></p><p><?=$dataArray['synopsis']?></p></div>
<?
if($dataArray['dvd_image'] == "None")
{
?>
<img id="img_<?=$recordCount?>" width="50" height="70"
src="images/dvds/none_small.jpg"
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
',img_<?=$recordCount?>.width
Quote:
+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
<?
}
else
{
?>
<img id="img_<?=$recordCount?>" width="50" height="70"
src="images/dvds/<?=$dataArray['dvd_image']?>"
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
',img_<?=$recordCount?>.width
Quote:
+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
<?
}
echo " <img
>
src='images/certs/".$certImage[$dataArray['certificate']].".gif'><BR>".$data
Array['title'];
Quote:
?>
</td>
<td width="4">&nbsp;</td>
<td><b>Released</b><br><?=$dataArray['year']?><br>
<b>Duration</b><br><?=$dataArray['duration']?><br>
<b>Rating</b><br><img alt="Rating: <?=$dataArray['rating']/2?>"
align="absmiddle"
src="images/ratings/pips<?=$dataArray['rating']?>.gif"></td>
<td width="4">&nbsp;</td>
<?
$recordCount++;
}
?>
</tr>
<?
}
}
----------------------------------
>
>
"Ian Davies" <iandan.dav@virgin.netwrote in message
news:j3wxg.1067$u4.703@newsfe3-win.ntli.net...
Quote:
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, so I have
extracted the records into hiddenfield, textareas, dropdown 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
Quote:
Quote:
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="commentselect.php" method="post"
enctype="multipart/form-data"
name="UpdateComments">
<table width="100%" border="0" cellpadding="0" cellspacing="2"
bgcolor="#FFFFFF">
<tr align="center" class="ListHeading">
<td width="20%" height="31">Category</td>
<td width="60%" height="31">Comment</td>
<td width="10%" height="31">Share</td>
</tr>
<tr class="BodyText">
<?php
while($row =& mysql_fetch_array($commentresults)) {
extract($row);

if ($i%2) {
$class = 'row1';
echo "<TR bgcolor=\"#CCCCCC\">\n";

} else {
$class = 'row2';
echo "<TR bgcolor=\"white\">\n";
}
$i += 1;
?>
<td width="20%" align="left" class="bodytext"><select
name="category[]" style="WIDTH: 90%">
<option value="<?php echo $row['TypeID']; ?>"><?php echo
$row['typedesc'];
Quote:
Quote:
?></option>
<?php
$commenttype = mysql_query("SELECT * FROM commenttype WHERE username =
'$username'");
if (!$commenttype) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
while($row1 =& mysql_fetch_array($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;
Quote:
Quote:
?>"></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" class="bodytext"><input
type="checkbox"
name="avail[]" value="checkbox" <?php share($available); ?> </td>
</tr>
<?php
}
?>
</table>
</form>

************************************************** **********
>
>

PSI_Orion
Guest
 
Posts: n/a
#4: Jul 27 '06

re: Using arrays to take records from a html table and update database


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 to 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 try and
explain how I would approach it.

Regards

PSI_Orion

"Ian Davies" <iandan.dav@virgin.netwrote in message
news:BwPxg.46899$1g.19898@newsfe1-win.ntli.net...
Quote:
Thanks for the reply
The problem Im having isnt creating a table with the records in it. That
works fine. Im trying to find a way where the users can modify the records
in a table and they are all updated in one go. I thought using 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 to 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.comwrote in message
news:uFIxg.62841$sz1.6724@newsfe6-gui.ntli.net...
Quote:
>If I understand you correctly, the way I would do it is the same way I
have
Quote:
>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
Quote:
>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($allRecords 0)
>{
> $recordCount = 0;
> while($recordCount < $allRecords)
> {
> if(($recordCount / 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_array($result);
> $dataArray['starring'] =
str_replace("\r","<BR>",$dataArray['starring']);
Quote:
> $dataArray['synopsis'] =
str_replace("\r","<BR>",$dataArray['synopsis']);
Quote:
> $dataArray['duration'] =
>date('H:i',strtotime($dataArray['duration']));
>?>
> <td background="images/barSilver.jpg" width="30"><?=($recordCount +
>1)?></td>
> <td width="4">&nbsp;</td>
> <td>
> <div class="div_info" style="position: absolute; width: 400px;
>z-index: 1; visibility: hidden;" id="infoLayer_<?=$recordCount?>"
>>
align="left"><b><u><?=$dataArray['title']?></u></b><p><u>Starring:</u><br><i
Quote:
>><?=$dataArray['starring']?></i></p><p><?=$dataArray['synopsis']?></p></div>
><?
> if($dataArray['dvd_image'] == "None")
> {
>?>
> <img id="img_<?=$recordCount?>" width="50" height="70"
>src="images/dvds/none_small.jpg"
>>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
',img_<?=$recordCount?>.width
Quote:
>+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
><?
> }
> else
> {
>?>
> <img id="img_<?=$recordCount?>" width="50" height="70"
>src="images/dvds/<?=$dataArray['dvd_image']?>"
>>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
',img_<?=$recordCount?>.width
Quote:
>+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
><?
> }
> echo " <img
>>
src='images/certs/".$certImage[$dataArray['certificate']].".gif'><BR>".$data
Array['title'];
Quote:
>?>
> </td>
> <td width="4">&nbsp;</td>
> <td><b>Released</b><br><?=$dataArray['year']?><br>
> <b>Duration</b><br><?=$dataArray['duration']?><br>
> <b>Rating</b><br><img alt="Rating: <?=$dataArray['rating']/2?>"
>align="absmiddle"
>src="images/ratings/pips<?=$dataArray['rating']?>.gif"></td>
> <td width="4">&nbsp;</td>
><?
> $recordCount++;
> }
>?>
> </tr>
><?
> }
>}
>----------------------------------
>>
>>
>"Ian Davies" <iandan.dav@virgin.netwrote in message
>news:j3wxg.1067$u4.703@newsfe3-win.ntli.net...
Quote:
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, so I have
extracted the records into hiddenfield, textareas, dropdown 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
Quote:
Quote:
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="commentselect.php" method="post"
enctype="multipart/form-data"
name="UpdateComments">
<table width="100%" border="0" cellpadding="0" cellspacing="2"
bgcolor="#FFFFFF">
<tr align="center" class="ListHeading">
<td width="20%" height="31">Category</td>
<td width="60%" height="31">Comment</td>
<td width="10%" height="31">Share</td>
</tr>
<tr class="BodyText">
<?php
while($row =& mysql_fetch_array($commentresults)) {
extract($row);
>
if ($i%2) {
$class = 'row1';
echo "<TR bgcolor=\"#CCCCCC\">\n";
>
} else {
$class = 'row2';
echo "<TR bgcolor=\"white\">\n";
}
$i += 1;
?>
<td width="20%" align="left" class="bodytext"><select
name="category[]" style="WIDTH: 90%">
<option value="<?php echo $row['TypeID']; ?>"><?php echo
$row['typedesc'];
Quote:
Quote:
?></option>
<?php
$commenttype = mysql_query("SELECT * FROM commenttype WHERE username =
'$username'");
if (!$commenttype) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
while($row1 =& mysql_fetch_array($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;
Quote:
Quote:
?>"></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" class="bodytext"><input
type="checkbox"
name="avail[]" value="checkbox" <?php share($available); ?> </td>
</tr>
<?php
}
?>
</table>
</form>
>
************************************************** **********
>
>
>>
>>
>
>

Ian Davies
Guest
 
Posts: n/a
#5: Jul 27 '06

re: Using arrays to take records from a html table and update database


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.comwrote in message
news:MQSxg.1434$v4.793@newsfe3-win.ntli.net...
Quote:
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 to adjust
your query accordingly. I don't have time right now to explain fully but
if
Quote:
you send me a personal email to orion at psiss dot com I will try and
explain how I would approach it.
>
Regards
>
PSI_Orion
>
"Ian Davies" <iandan.dav@virgin.netwrote in message
news:BwPxg.46899$1g.19898@newsfe1-win.ntli.net...
Quote:
Thanks for the reply
The problem Im having isnt creating a table with the records in it. That
works fine. Im trying to find a way where the users can modify the
records
Quote:
Quote:
in a table and they are all updated in one go. I thought using arrays
would
be the answer, but Im not that familiar with them. At the moment the
users
Quote:
Quote:
click a button at the begining of a row and that record is displated on
a
Quote:
Quote:
new page where it can be updated. But this requires the user to click
and
Quote:
Quote:
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
Quote:
Quote:
script would take each row in turn and update that row in te database,
it
Quote:
Quote:
would then loop through all the rows in the table and update each
accordingly

Hope this explains it better

Ian

"PSI_Orion" <orion@psiss.comwrote in message
news:uFIxg.62841$sz1.6724@newsfe6-gui.ntli.net...
Quote:
If I understand you correctly, the way I would do it is the same way I
have
Quote:
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
Quote:
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
Quote:
Quote:
Quote:
which you can view at "http:// mydvds . psiss . com"
>
------------------------------------------------------
if($allRecords 0)
{
$recordCount = 0;
while($recordCount < $allRecords)
{
if(($recordCount / 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_array($result);
$dataArray['starring'] =
str_replace("\r","<BR>",$dataArray['starring']);
Quote:
$dataArray['synopsis'] =
str_replace("\r","<BR>",$dataArray['synopsis']);
Quote:
$dataArray['duration'] =
date('H:i',strtotime($dataArray['duration']));
?>
<td background="images/barSilver.jpg" width="30"><?=($recordCount +
1)?></td>
<td width="4">&nbsp;</td>
<td>
<div class="div_info" style="position: absolute; width: 400px;
z-index: 1; visibility: hidden;" id="infoLayer_<?=$recordCount?>"
>
align="left"><b><u><?=$dataArray['title']?></u></b><p><u>Starring:</u><br><i
Quote:
>
Quote:
>><?=$dataArray['starring']?></i></p><p><?=$dataArray['synopsis']?></p></div
>
Quote:
Quote:
<?
if($dataArray['dvd_image'] == "None")
{
?>
<img id="img_<?=$recordCount?>" width="50" height="70"
src="images/dvds/none_small.jpg"
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
',img_<?=$recordCount?>.width
Quote:
+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
<?
}
else
{
?>
<img id="img_<?=$recordCount?>" width="50" height="70"
src="images/dvds/<?=$dataArray['dvd_image']?>"
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
',img_<?=$recordCount?>.width
Quote:
+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
<?
}
echo " <img
>
src='images/certs/".$certImage[$dataArray['certificate']].".gif'><BR>".$data
Quote:
Quote:
Array['title'];
Quote:
?>
</td>
<td width="4">&nbsp;</td>
<td><b>Released</b><br><?=$dataArray['year']?><br>
<b>Duration</b><br><?=$dataArray['duration']?><br>
<b>Rating</b><br><img alt="Rating: <?=$dataArray['rating']/2?>"
align="absmiddle"
src="images/ratings/pips<?=$dataArray['rating']?>.gif"></td>
<td width="4">&nbsp;</td>
<?
$recordCount++;
}
?>
</tr>
<?
}
}
----------------------------------
>
>
"Ian Davies" <iandan.dav@virgin.netwrote in message
news:j3wxg.1067$u4.703@newsfe3-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
Quote:
Quote:
Quote:
record in a hidden field)
I wish the user to be able to edit the data in the table, so I have
extracted the records into hiddenfield, textareas, dropdown 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
Quote:
Quote:
Quote:
similar with just one record but am stuck as to how I use the arrays
of
Quote:
Quote:
a
Quote:
number of form elements together

My code for the table is below but I dont know how the script should
go
Quote:
Quote:
Quote:
when
the form is submitted to add each row in turn
Help greatly appreciated
Ian
************************************************** ********************
Quote:
Quote:
Quote:
<form action="commentselect.php" method="post"
enctype="multipart/form-data"
name="UpdateComments">
<table width="100%" border="0" cellpadding="0" cellspacing="2"
bgcolor="#FFFFFF">
<tr align="center" class="ListHeading">
<td width="20%" height="31">Category</td>
<td width="60%" height="31">Comment</td>
<td width="10%" height="31">Share</td>
</tr>
<tr class="BodyText">
<?php
while($row =& mysql_fetch_array($commentresults)) {
extract($row);

if ($i%2) {
$class = 'row1';
echo "<TR bgcolor=\"#CCCCCC\">\n";

} else {
$class = 'row2';
echo "<TR bgcolor=\"white\">\n";
}
$i += 1;
?>
<td width="20%" align="left" class="bodytext"><select
name="category[]" style="WIDTH: 90%">
<option value="<?php echo $row['TypeID']; ?>"><?php echo
$row['typedesc'];
Quote:
?></option>
<?php
$commenttype = mysql_query("SELECT * FROM commenttype WHERE username
=
Quote:
Quote:
Quote:
'$username'");
if (!$commenttype) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
while($row1 =& mysql_fetch_array($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;
Quote:
?>"></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" class="bodytext"><input
type="checkbox"
name="avail[]" value="checkbox" <?php share($available); ?>>
</td>
Quote:
Quote:
Quote:
</tr>
<?php
}
?>
</table>
</form>

************************************************** **********


>
>
>
>

PSI_Orion
Guest
 
Posts: n/a
#6: Jul 27 '06

re: Using arrays to take records from a html table and update database


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@virgin.netwrote in message
news:Q9%xg.52408$IU2.3744@newsfe2-win.ntli.net...
Quote:
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.comwrote in message
news:MQSxg.1434$v4.793@newsfe3-win.ntli.net...
Quote:
>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 to adjust
>your query accordingly. I don't have time right now to explain fully but
if
Quote:
>you send me a personal email to orion at psiss dot com I will try and
>explain how I would approach it.
>>
>Regards
>>
>PSI_Orion
>>
>"Ian Davies" <iandan.dav@virgin.netwrote in message
>news:BwPxg.46899$1g.19898@newsfe1-win.ntli.net...
Quote:
Thanks for the reply
The problem Im having isnt creating a table with the records in it.
That
works fine. Im trying to find a way where the users can modify the
records
Quote:
Quote:
in a table and they are all updated in one go. I thought using arrays
would
be the answer, but Im not that familiar with them. At the moment the
users
Quote:
Quote:
click a button at the begining of a row and that record is displated on
a
Quote:
Quote:
new page where it can be updated. But this requires the user to click
and
Quote:
Quote:
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
Quote:
Quote:
script would take each row in turn and update that row in te database,
it
Quote:
Quote:
would then loop through all the rows in the table and update each
accordingly
>
Hope this explains it better
>
Ian
>
"PSI_Orion" <orion@psiss.comwrote in message
news:uFIxg.62841$sz1.6724@newsfe6-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
Quote:
Quote:
>which you can view at "http:// mydvds . psiss . com"
>>
>------------------------------------------------------
>if($allRecords 0)
>{
> $recordCount = 0;
> while($recordCount < $allRecords)
> {
> if(($recordCount / 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_array($result);
> $dataArray['starring'] =
str_replace("\r","<BR>",$dataArray['starring']);
> $dataArray['synopsis'] =
str_replace("\r","<BR>",$dataArray['synopsis']);
> $dataArray['duration'] =
>date('H:i',strtotime($dataArray['duration']));
>?>
> <td background="images/barSilver.jpg" width="30"><?=($recordCount +
>1)?></td>
> <td width="4">&nbsp;</td>
> <td>
> <div class="div_info" style="position: absolute; width: 400px;
>z-index: 1; visibility: hidden;" id="infoLayer_<?=$recordCount?>"
>>
>
align="left"><b><u><?=$dataArray['title']?></u></b><p><u>Starring:</u><br><i
Quote:
>>
Quote:
>>><?=$dataArray['starring']?></i></p><p><?=$dataArray['synopsis']?></p></div
>>
Quote:
><?
> if($dataArray['dvd_image'] == "None")
> {
>?>
> <img id="img_<?=$recordCount?>" width="50" height="70"
>src="images/dvds/none_small.jpg"
>>
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
',img_<?=$recordCount?>.width
>+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
><?
> }
> else
> {
>?>
> <img id="img_<?=$recordCount?>" width="50" height="70"
>src="images/dvds/<?=$dataArray['dvd_image']?>"
>>
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
',img_<?=$recordCount?>.width
>+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
><?
> }
> echo " <img
>>
>
src='images/certs/".$certImage[$dataArray['certificate']].".gif'><BR>".$data
Quote:
Quote:
Array['title'];
>?>
> </td>
> <td width="4">&nbsp;</td>
> <td><b>Released</b><br><?=$dataArray['year']?><br>
> <b>Duration</b><br><?=$dataArray['duration']?><br>
> <b>Rating</b><br><img alt="Rating: <?=$dataArray['rating']/2?>"
>align="absmiddle"
>src="images/ratings/pips<?=$dataArray['rating']?>.gif"></td>
> <td width="4">&nbsp;</td>
><?
> $recordCount++;
> }
>?>
> </tr>
><?
> }
>}
>----------------------------------
>>
>>
>"Ian Davies" <iandan.dav@virgin.netwrote in message
>news:j3wxg.1067$u4.703@newsfe3-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
Quote:
Quote:
record in a hidden field)
I wish the user to be able to edit the data in the table, so I have
extracted the records into hiddenfield, textareas, dropdown 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
Quote:
Quote:
similar with just one record but am stuck as to how I use the arrays
of
Quote:
Quote:
a
number of form elements together
>
My code for the table is below but I dont know how the script should
go
Quote:
Quote:
when
the form is submitted to add each row in turn
Help greatly appreciated
Ian
>
************************************************** ********************
Quote:
Quote:
<form action="commentselect.php" method="post"
enctype="multipart/form-data"
name="UpdateComments">
<table width="100%" border="0" cellpadding="0" cellspacing="2"
bgcolor="#FFFFFF">
<tr align="center" class="ListHeading">
<td width="20%" height="31">Category</td>
<td width="60%" height="31">Comment</td>
<td width="10%" height="31">Share</td>
</tr>
<tr class="BodyText">
<?php
while($row =& mysql_fetch_array($commentresults)) {
extract($row);
>
if ($i%2) {
$class = 'row1';
echo "<TR bgcolor=\"#CCCCCC\">\n";
>
} else {
$class = 'row2';
echo "<TR bgcolor=\"white\">\n";
}
$i += 1;
?>
<td width="20%" align="left" class="bodytext"><select
name="category[]" style="WIDTH: 90%">
<option value="<?php echo $row['TypeID']; ?>"><?php echo
$row['typedesc'];
?></option>
<?php
$commenttype = mysql_query("SELECT * FROM commenttype WHERE username
=
Quote:
Quote:
'$username'");
if (!$commenttype) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
while($row1 =& mysql_fetch_array($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" class="bodytext"><input
type="checkbox"
name="avail[]" value="checkbox" <?php share($available); ?>>
</td>
Quote:
Quote:
</tr>
<?php
}
?>
</table>
</form>
>
************************************************** **********
>
>
>>
>>
>
>
>>
>>
>
>

Ian Davies
Guest
 
Posts: n/a
#7: Jul 27 '06

re: Using arrays to take records from a html table and update database


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 the
arrays appropriately

Cheers
Ian
also I greatly appreciate your assistance


"PSI_Orion" <orion@psiss.comwrote in message
news:e71yg.46974$1g.21477@newsfe1-win.ntli.net...
Quote:
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@virgin.netwrote in message
news:Q9%xg.52408$IU2.3744@newsfe2-win.ntli.net...
Quote:
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
Quote:
Quote:
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.comwrote in message
news:MQSxg.1434$v4.793@newsfe3-win.ntli.net...
Quote:
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 to
adjust
Quote:
Quote:
Quote:
your query accordingly. I don't have time right now to explain fully
but
Quote:
Quote:
if
Quote:
you send me a personal email to orion at psiss dot com I will try and
explain how I would approach it.
>
Regards
>
PSI_Orion
>
"Ian Davies" <iandan.dav@virgin.netwrote in message
news:BwPxg.46899$1g.19898@newsfe1-win.ntli.net...
Thanks for the reply
The problem Im having isnt creating a table with the records in it.
That
works fine. Im trying to find a way where the users can modify the
records
Quote:
in a table and they are all updated in one go. I thought using arrays
would
be the answer, but Im not that familiar with them. At the moment the
users
Quote:
click a button at the begining of a row and that record is displated
on
Quote:
Quote:
a
Quote:
new page where it can be updated. But this requires the user to click
and
Quote:
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
Quote:
script would take each row in turn and update that row in te
database,
Quote:
Quote:
it
Quote:
would then loop through all the rows in the table and update each
accordingly

Hope this explains it better

Ian

"PSI_Orion" <orion@psiss.comwrote in message
news:uFIxg.62841$sz1.6724@newsfe6-gui.ntli.net...
If I understand you correctly, the way I would do it is the same way
I
Quote:
Quote:
Quote:
have
my DVD database. This is rather than have the name of the elements
as
Quote:
Quote:
Quote:
"commindex[]" etc, actually place the table creation inside your
while
Quote:
Quote:
Quote:
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
Quote:
which you can view at "http:// mydvds . psiss . com"
>
------------------------------------------------------
if($allRecords 0)
{
$recordCount = 0;
while($recordCount < $allRecords)
{
if(($recordCount / 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_array($result);
$dataArray['starring'] =
str_replace("\r","<BR>",$dataArray['starring']);
$dataArray['synopsis'] =
str_replace("\r","<BR>",$dataArray['synopsis']);
$dataArray['duration'] =
date('H:i',strtotime($dataArray['duration']));
?>
<td background="images/barSilver.jpg" width="30"><?=($recordCount
+
Quote:
Quote:
Quote:
1)?></td>
<td width="4">&nbsp;</td>
<td>
<div class="div_info" style="position: absolute; width: 400px;
z-index: 1; visibility: hidden;" id="infoLayer_<?=$recordCount?>"
>
align="left"><b><u><?=$dataArray['title']?></u></b><p><u>Starring:</u><br><i
Quote:
Quote:
Quote:
>
>
Quote:
Quote:
>>><?=$dataArray['starring']?></i></p><p><?=$dataArray['synopsis']?></p></di
v
Quote:
Quote:
Quote:
>
<?
if($dataArray['dvd_image'] == "None")
{
?>
<img id="img_<?=$recordCount?>" width="50" height="70"
src="images/dvds/none_small.jpg"
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
Quote:
',img_<?=$recordCount?>.width
+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
<?
}
else
{
?>
<img id="img_<?=$recordCount?>" width="50" height="70"
src="images/dvds/<?=$dataArray['dvd_image']?>"
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
Quote:
',img_<?=$recordCount?>.width
+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
<?
}
echo " <img
>
src='images/certs/".$certImage[$dataArray['certificate']].".gif'><BR>".$data
Quote:
Quote:
Quote:
Array['title'];
?>
</td>
<td width="4">&nbsp;</td>
<td><b>Released</b><br><?=$dataArray['year']?><br>
<b>Duration</b><br><?=$dataArray['duration']?><br>
<b>Rating</b><br><img alt="Rating: <?=$dataArray['rating']/2?>"
align="absmiddle"
src="images/ratings/pips<?=$dataArray['rating']?>.gif"></td>
<td width="4">&nbsp;</td>
<?
$recordCount++;
}
?>
</tr>
<?
}
}
----------------------------------
>
>
"Ian Davies" <iandan.dav@virgin.netwrote in message
news:j3wxg.1067$u4.703@newsfe3-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
Quote:
Quote:
the
Quote:
record in a hidden field)
I wish the user to be able to edit the data in the table, so I
have
Quote:
Quote:
Quote:
extracted the records into hiddenfield, textareas, dropdown list
and
Quote:
Quote:
Quote:
checkbox so that they can make changes.
I named these elements as arrays and wish to run an sql to take
each
Quote:
Quote:
Quote:
row
in
turn (and any changes made) and update the mysql table. I did
something
Quote:
similar with just one record but am stuck as to how I use the
arrays
Quote:
Quote:
of
Quote:
a
number of form elements together

My code for the table is below but I dont know how the script
should
Quote:
Quote:
go
Quote:
when
the form is submitted to add each row in turn
Help greatly appreciated
Ian
************************************************** ********************
Quote:
<form action="commentselect.php" method="post"
enctype="multipart/form-data"
name="UpdateComments">
<table width="100%" border="0" cellpadding="0" cellspacing="2"
bgcolor="#FFFFFF">
<tr align="center" class="ListHeading">
<td width="20%" height="31">Category</td>
<td width="60%" height="31">Comment</td>
<td width="10%" height="31">Share</td>
</tr>
<tr class="BodyText">
<?php
while($row =& mysql_fetch_array($commentresults)) {
extract($row);

if ($i%2) {
$class = 'row1';
echo "<TR bgcolor=\"#CCCCCC\">\n";

} else {
$class = 'row2';
echo "<TR bgcolor=\"white\">\n";
}
$i += 1;
?>
<td width="20%" align="left" class="bodytext"><select
name="category[]" style="WIDTH: 90%">
<option value="<?php echo $row['TypeID']; ?>"><?php echo
$row['typedesc'];
?></option>
<?php
$commenttype = mysql_query("SELECT * FROM commenttype WHERE
username
Quote:
Quote:
=
Quote:
'$username'");
if (!$commenttype) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
while($row1 =& mysql_fetch_array($commenttype)) {
extract($row1);
?>
<option value="<?php echo $row1['TypeID'];
?>"><?php
Quote:
Quote:
Quote:
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" class="bodytext"><input
type="checkbox"
name="avail[]" value="checkbox" <?php share($available); ?>>
</td>
Quote:
</tr>
<?php
}
?>
</table>
</form>

************************************************** **********


>
>


>
>
>
>

Ian Davies
Guest
 
Posts: n/a
#8: Jul 27 '06

re: Using arrays to take records from a html table and update database


'....and a hidden field to contain...'
SHOULD READ
'....and I also have a hidden field that contains...'


ian


"Ian Davies" <iandan.dav@virgin.netwrote in message
news:EJ2yg.63520$Z61.54928@newsfe4-win.ntli.net...
Quote:
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
Quote:
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
Quote:
a loop with an sql update. But Im lost as to how to create and use the
arrays appropriately
>
Cheers
Ian
also I greatly appreciate your assistance
>
>
"PSI_Orion" <orion@psiss.comwrote in message
news:e71yg.46974$1g.21477@newsfe1-win.ntli.net...
Quote:
I'm presuming comment is the textbox (or do you use textarea), category
is
Quote:
Quote:
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@virgin.netwrote in message
news:Q9%xg.52408$IU2.3744@newsfe2-win.ntli.net...
Quote:
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
Quote:
Quote:
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.comwrote in message
news:MQSxg.1434$v4.793@newsfe3-win.ntli.net...
>Yes, that explains it much better. Which field is it you are trying
to
Quote:
Quote:
Quote:
>amend? Is it a simple yes/no type field? If so then you need to
adjust
Quote:
Quote:
>your query accordingly. I don't have time right now to explain fully
but
Quote:
Quote:
if
>you send me a personal email to orion at psiss dot com I will try and
>explain how I would approach it.
>>
>Regards
>>
>PSI_Orion
>>
>"Ian Davies" <iandan.dav@virgin.netwrote in message
>news:BwPxg.46899$1g.19898@newsfe1-win.ntli.net...
Thanks for the reply
The problem Im having isnt creating a table with the records in it.
That
works fine. Im trying to find a way where the users can modify the
records
in a table and they are all updated in one go. I thought using
arrays
Quote:
Quote:
Quote:
would
be the answer, but Im not that familiar with them. At the moment
the
Quote:
Quote:
Quote:
users
click a button at the begining of a row and that record is
displated
Quote:
on
Quote:
Quote:
a
new page where it can be updated. But this requires the user to
click
Quote:
Quote:
Quote:
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
Quote:
Quote:
Quote:
some
script would take each row in turn and update that row in te
database,
Quote:
Quote:
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.comwrote in message
news:uFIxg.62841$sz1.6724@newsfe6-gui.ntli.net...
>If I understand you correctly, the way I would do it is the same
way
Quote:
I
Quote:
Quote:
have
>my DVD database. This is rather than have the name of the
elements
Quote:
as
Quote:
Quote:
>"commindex[]" etc, actually place the table creation inside your
while
Quote:
Quote:
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
Quote:
Quote:
Quote:
code
>which you can view at "http:// mydvds . psiss . com"
>>
>------------------------------------------------------
>if($allRecords 0)
>{
> $recordCount = 0;
> while($recordCount < $allRecords)
> {
> if(($recordCount / 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_array($result);
> $dataArray['starring'] =
str_replace("\r","<BR>",$dataArray['starring']);
> $dataArray['synopsis'] =
str_replace("\r","<BR>",$dataArray['synopsis']);
> $dataArray['duration'] =
>date('H:i',strtotime($dataArray['duration']));
>?>
> <td background="images/barSilver.jpg"
width="30"><?=($recordCount
Quote:
+
Quote:
Quote:
>1)?></td>
> <td width="4">&nbsp;</td>
> <td>
> <div class="div_info" style="position: absolute; width:
400px;
Quote:
Quote:
Quote:
>z-index: 1; visibility: hidden;" id="infoLayer_<?=$recordCount?>"
>>
>
>
>
align="left"><b><u><?=$dataArray['title']?></u></b><p><u>Starring:</u><br><i
Quote:
Quote:
Quote:
>>
>
Quote:
Quote:
>>><?=$dataArray['starring']?></i></p><p><?=$dataArray['synopsis']?></p></di
v
Quote:
Quote:
>>
><?
> if($dataArray['dvd_image'] == "None")
> {
>?>
> <img id="img_<?=$recordCount?>" width="50" height="70"
>src="images/dvds/none_small.jpg"
>>
>
>
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
Quote:
',img_<?=$recordCount?>.width
>+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
><?
> }
> else
> {
>?>
> <img id="img_<?=$recordCount?>" width="50" height="70"
>src="images/dvds/<?=$dataArray['dvd_image']?>"
>>
>
>
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
Quote:
',img_<?=$recordCount?>.width
>+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
><?
> }
> echo " <img
>>
>
>
>
src='images/certs/".$certImage[$dataArray['certificate']].".gif'><BR>".$data
Quote:
Quote:
Quote:
Array['title'];
>?>
> </td>
> <td width="4">&nbsp;</td>
> <td><b>Released</b><br><?=$dataArray['year']?><br>
> <b>Duration</b><br><?=$dataArray['duration']?><br>
> <b>Rating</b><br><img alt="Rating: <?=$dataArray['rating']/2?>"
>align="absmiddle"
>src="images/ratings/pips<?=$dataArray['rating']?>.gif"></td>
> <td width="4">&nbsp;</td>
><?
> $recordCount++;
> }
>?>
> </tr>
><?
> }
>}
>----------------------------------
>>
>>
>"Ian Davies" <iandan.dav@virgin.netwrote in message
>news:j3wxg.1067$u4.703@newsfe3-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
Quote:
Quote:
the
record in a hidden field)
I wish the user to be able to edit the data in the table, so I
have
Quote:
Quote:
extracted the records into hiddenfield, textareas, dropdown list
and
Quote:
Quote:
checkbox so that they can make changes.
I named these elements as arrays and wish to run an sql to take
each
Quote:
Quote:
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
Quote:
Quote:
of
a
number of form elements together
>
My code for the table is below but I dont know how the script
should
Quote:
Quote:
go
when
the form is submitted to add each row in turn
Help greatly appreciated
Ian
>
************************************************** ********************
<form action="commentselect.php" method="post"
enctype="multipart/form-data"
name="UpdateComments">
<table width="100%" border="0" cellpadding="0" cellspacing="2"
bgcolor="#FFFFFF">
<tr align="center" class="ListHeading">
<td width="20%" height="31">Category</td>
<td width="60%" height="31">Comment</td>
<td width="10%" height="31">Share</td>
</tr>
<tr class="BodyText">
<?php
while($row =& mysql_fetch_array($commentresults)) {
extract($row);
>
if ($i%2) {
$class = 'row1';
echo "<TR bgcolor=\"#CCCCCC\">\n";
>
} else {
$class = 'row2';
echo "<TR bgcolor=\"white\">\n";
}
$i += 1;
?>
<td width="20%" align="left" class="bodytext"><select
name="category[]" style="WIDTH: 90%">
<option value="<?php echo $row['TypeID']; ?>"><?php echo
$row['typedesc'];
?></option>
<?php
$commenttype = mysql_query("SELECT * FROM commenttype WHERE
username
Quote:
Quote:
=
'$username'");
if (!$commenttype) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
while($row1 =& mysql_fetch_array($commenttype)) {
extract($row1);
?>
<option value="<?php echo $row1['TypeID'];
?>"><?php
Quote:
Quote:
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
Quote:
Quote:
Quote:
name="comm[]" rows="2" style="WIDTH: 99%"><?php echo $comment;
?></textarea></td>
<td width="10%" align="center" class="bodytext"><input
type="checkbox"
name="avail[]" value="checkbox" <?php share($available); ?>>
</td>
</tr>
<?php
}
?>
</table>
</form>
>
************************************************** **********
>
>
>>
>>
>
>
>>
>>
>
>
>
>

PSI_Orion
Guest
 
Posts: n/a
#9: Jul 27 '06

re: Using arrays to take records from a html table and update database


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 be
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 more 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@virgin.netwrote in message
news:KL2yg.63521$Z61.2758@newsfe4-win.ntli.net...
Quote:
'....and a hidden field to contain...'
SHOULD READ
'....and I also have a hidden field that contains...'
>
>
ian
>
>
"Ian Davies" <iandan.dav@virgin.netwrote in message
news:EJ2yg.63520$Z61.54928@newsfe4-win.ntli.net...
Quote:
>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
Quote:
>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
Quote:
>a loop with an sql update. But Im lost as to how to create and use the
>arrays appropriately
>>
>Cheers
>Ian
>also I greatly appreciate your assistance
>>
>>
>"PSI_Orion" <orion@psiss.comwrote in message
>news:e71yg.46974$1g.21477@newsfe1-win.ntli.net...
Quote:
I'm presuming comment is the textbox (or do you use textarea), category
is
Quote:
Quote:
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@virgin.netwrote in message
news:Q9%xg.52408$IU2.3744@newsfe2-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
Quote:
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.comwrote in message
news:MQSxg.1434$v4.793@newsfe3-win.ntli.net...
>Yes, that explains it much better. Which field is it you are trying
to
Quote:
Quote:
>amend? Is it a simple yes/no type field? If so then you need to
>adjust
Quote:
>your query accordingly. I don't have time right now to explain
>fully
>but
Quote:
if
>you send me a personal email to orion at psiss dot com I will try
>and
>explain how I would approach it.
>>
>Regards
>>
>PSI_Orion
>>
>"Ian Davies" <iandan.dav@virgin.netwrote in message
>news:BwPxg.46899$1g.19898@newsfe1-win.ntli.net...
Thanks for the reply
The problem Im having isnt creating a table with the records in
it.
That
works fine. Im trying to find a way where the users can modify the
records
in a table and they are all updated in one go. I thought using
arrays
Quote:
Quote:
would
be the answer, but Im not that familiar with them. At the moment
the
Quote:
Quote:
users
click a button at the begining of a row and that record is
displated
Quote:
>on
Quote:
a
new page where it can be updated. But this requires the user to
click
Quote:
Quote:
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
Quote:
Quote:
some
script would take each row in turn and update that row in te
>database,
Quote:
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.comwrote in message
news:uFIxg.62841$sz1.6724@newsfe6-gui.ntli.net...
>If I understand you correctly, the way I would do it is the same
way
Quote:
>I
Quote:
have
>my DVD database. This is rather than have the name of the
elements
Quote:
>as
Quote:
>"commindex[]" etc, actually place the table creation inside your
>while
Quote:
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
Quote:
Quote:
code
>which you can view at "http:// mydvds . psiss . com"
>>
>------------------------------------------------------
>if($allRecords 0)
>{
> $recordCount = 0;
> while($recordCount < $allRecords)
> {
> if(($recordCount / 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_array($result);
> $dataArray['starring'] =
str_replace("\r","<BR>",$dataArray['starring']);
> $dataArray['synopsis'] =
str_replace("\r","<BR>",$dataArray['synopsis']);
> $dataArray['duration'] =
>date('H:i',strtotime($dataArray['duration']));
>?>
> <td background="images/barSilver.jpg"
width="30"><?=($recordCount
Quote:
>+
Quote:
>1)?></td>
> <td width="4">&nbsp;</td>
> <td>
> <div class="div_info" style="position: absolute; width:
400px;
Quote:
Quote:
>z-index: 1; visibility: hidden;" id="infoLayer_<?=$recordCount?>"
>>
>
>
>>
align="left"><b><u><?=$dataArray['title']?></u></b><p><u>Starring:</u><br><i
Quote:
Quote:
>>
>
>>
Quote:
>>>><?=$dataArray['starring']?></i></p><p><?=$dataArray['synopsis']?></p></di
>v
Quote:
>>
><?
> if($dataArray['dvd_image'] == "None")
> {
>?>
> <img id="img_<?=$recordCount?>" width="50" height="70"
>src="images/dvds/none_small.jpg"
>>
>
>
>>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
',img_<?=$recordCount?>.width
>+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
><?
> }
> else
> {
>?>
> <img id="img_<?=$recordCount?>" width="50" height="70"
>src="images/dvds/<?=$dataArray['dvd_image']?>"
>>
>
>
>>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
',img_<?=$recordCount?>.width
>+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
><?
> }
> echo " <img
>>
>
>
>>
src='images/certs/".$certImage[$dataArray['certificate']].".gif'><BR>".$data
Quote:
Quote:
Array['title'];
>?>
> </td>
> <td width="4">&nbsp;</td>
> <td><b>Released</b><br><?=$dataArray['year']?><br>
> <b>Duration</b><br><?=$dataArray['duration']?><br>
> <b>Rating</b><br><img alt="Rating:
><?=$dataArray['rating']/2?>"
>align="absmiddle"
>src="images/ratings/pips<?=$dataArray['rating']?>.gif"></td>
> <td width="4">&nbsp;</td>
><?
> $recordCount++;
> }
>?>
> </tr>
><?
> }
>}
>----------------------------------
>>
>>
>"Ian Davies" <iandan.dav@virgin.netwrote in message
>news:j3wxg.1067$u4.703@newsfe3-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
Quote:
the
record in a hidden field)
I wish the user to be able to edit the data in the table, so I
>have
Quote:
extracted the records into hiddenfield, textareas, dropdown
list
>and
Quote:
checkbox so that they can make changes.
I named these elements as arrays and wish to run an sql to take
>each
Quote:
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
Quote:
of
a
number of form elements together
>
My code for the table is below but I dont know how the script
>should
Quote:
go
when
the form is submitted to add each row in turn
Help greatly appreciated
Ian
>
************************************************** ********************
<form action="commentselect.php" method="post"
enctype="multipart/form-data"
name="UpdateComments">
<table width="100%" border="0" cellpadding="0" cellspacing="2"
bgcolor="#FFFFFF">
<tr align="center" class="ListHeading">
<td width="20%" height="31">Category</td>
<td width="60%" height="31">Comment</td>
<td width="10%" height="31">Share</td>
</tr>
<tr class="BodyText">
<?php
while($row =& mysql_fetch_array($commentresults)) {
extract($row);
>
if ($i%2) {
$class = 'row1';
echo "<TR bgcolor=\"#CCCCCC\">\n";
>
} else {
$class = 'row2';
echo "<TR bgcolor=\"white\">\n";
}
$i += 1;
?>
<td width="20%" align="left" class="bodytext"><select
name="category[]" style="WIDTH: 90%">
<option value="<?php echo $row['TypeID']; ?>"><?php echo
$row['typedesc'];
?></option>
<?php
$commenttype = mysql_query("SELECT * FROM commenttype WHERE
>username
Quote:
=
'$username'");
if (!$commenttype) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
while($row1 =& mysql_fetch_array($commenttype)) {
extract($row1);
?>
<option value="<?php echo $row1['TypeID'];
>?>"><?php
Quote:
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
Quote:
Quote:
name="comm[]" rows="2" style="WIDTH: 99%"><?php echo $comment;
?></textarea></td>
<td width="10%" align="center" class="bodytext"><input
type="checkbox"
name="avail[]" value="checkbox" <?php share($available); ?>>
</td>
</tr>
<?php
}
?>
</table>
</form>
>
************************************************** **********
>
>
>>
>>
>
>
>>
>>
>
>
>
>
>>
>>
>
>

Ian Davies
Guest
 
Posts: n/a
#10: Jul 27 '06

re: Using arrays to take records from a html table and update database


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 changes
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 be 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.comwrote in message
news:aE4yg.68433$sz1.47146@newsfe6-gui.ntli.net...
Quote:
Take a look at http://www.psiss.com/dummy to see if I'm on the right
lines.
Quote:
Obviously it's not nicely formatted and the "Update" checkboxes would be
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 more
but
Quote:
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@virgin.netwrote in message
news:KL2yg.63521$Z61.2758@newsfe4-win.ntli.net...
Quote:
'....and a hidden field to contain...'
SHOULD READ
'....and I also have a hidden field that contains...'


ian


"Ian Davies" <iandan.dav@virgin.netwrote in message
news:EJ2yg.63520$Z61.54928@newsfe4-win.ntli.net...
Quote:
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
Quote:
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
Quote:
Quote:
in
Quote:
a loop with an sql update. But Im lost as to how to create and use the
arrays appropriately
>
Cheers
Ian
also I greatly appreciate your assistance
>
>
"PSI_Orion" <orion@psiss.comwrote in message
news:e71yg.46974$1g.21477@newsfe1-win.ntli.net...
I'm presuming comment is the textbox (or do you use textarea),
category
Quote:
Quote:
is
Quote:
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@virgin.netwrote in message
news:Q9%xg.52408$IU2.3744@newsfe2-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
Quote:
Quote:
Quote:
dropdown list and a tick box which are in the other columns.
Ian
>
>
"PSI_Orion" <orion@psiss.comwrote in message
news:MQSxg.1434$v4.793@newsfe3-win.ntli.net...
>Yes, that explains it much better. Which field is it you are
trying
Quote:
Quote:
to
Quote:
>amend? Is it a simple yes/no type field? If so then you need to
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 try
>and
>explain how I would approach it.
>>
>Regards
>>
>PSI_Orion
>>
>"Ian Davies" <iandan.dav@virgin.netwrote in message
>news:BwPxg.46899$1g.19898@newsfe1-win.ntli.net...
Thanks for the reply
The problem Im having isnt creating a table with the records in
it.
That
works fine. Im trying to find a way where the users can modify
the
Quote:
Quote:
Quote:
records
in a table and they are all updated in one go. I thought using
arrays
Quote:
would
be the answer, but Im not that familiar with them. At the moment
the
Quote:
users
click a button at the begining of a row and that record is
displated
Quote:
on
a
new page where it can be updated. But this requires the user to
click
Quote:
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
Quote:
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
Quote:
Quote:
Quote:
accordingly
>
Hope this explains it better
>
Ian
>
"PSI_Orion" <orion@psiss.comwrote in message
news:uFIxg.62841$sz1.6724@newsfe6-gui.ntli.net...
>If I understand you correctly, the way I would do it is the
same
Quote:
Quote:
way
Quote:
I
have
>my DVD database. This is rather than have the name of the
elements
Quote:
as
>"commindex[]" etc, actually place the table creation inside
your
Quote:
Quote:
Quote:
while
loop
>and increment the naming field using the i variable you use,
ie:
Quote:
Quote:
Quote:
>"commindex[<?=$i?>]".
>>
>As an example of what I mean, here is an excerpt of my DVD
database
Quote:
code
>which you can view at "http:// mydvds . psiss . com"
>>
>------------------------------------------------------
>if($allRecords 0)
>{
> $recordCount = 0;
> while($recordCount < $allRecords)
> {
> if(($recordCount / 2) % 2 == 1)
> {
>?>
> <tr align="center" class="tr_even">
><?
> }
> else
> {
>?>
> <tr align="center" class="tr_odd">
><?
> }
> for($colCount = 0; $colCount < 2 && $recordCount <
$allRecords;
Quote:
Quote:
Quote:
>$colCount++)
> {
> $dataArray = mysql_fetch_array($result);
> $dataArray['starring'] =
str_replace("\r","<BR>",$dataArray['starring']);
> $dataArray['synopsis'] =
str_replace("\r","<BR>",$dataArray['synopsis']);
> $dataArray['duration'] =
>date('H:i',strtotime($dataArray['duration']));
>?>
> <td background="images/barSilver.jpg"
width="30"><?=($recordCount
Quote:
+
>1)?></td>
> <td width="4">&nbsp;</td>
> <td>
> <div class="div_info" style="position: absolute; width:
400px;
Quote:
>z-index: 1; visibility: hidden;"
id="infoLayer_<?=$recordCount?>"
Quote:
Quote:
Quote:
>>
>
>
>
align="left"><b><u><?=$dataArray['title']?></u></b><p><u>Starring:</u><br><i
Quote:
Quote:
Quote:
>>

>
>
Quote:
Quote:
>>>><?=$dataArray['starring']?></i></p><p><?=$dataArray['synopsis']?></p></d
i
Quote:
Quote:
Quote:
v
>>
><?
> if($dataArray['dvd_image'] == "None")
> {
>?>
> <img id="img_<?=$recordCount?>" width="50" height="70"
>src="images/dvds/none_small.jpg"
>>
>
>
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
Quote:
',img_<?=$recordCount?>.width
>+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
><?
> }
> else
> {
>?>
> <img id="img_<?=$recordCount?>" width="50" height="70"
>src="images/dvds/<?=$dataArray['dvd_image']?>"
>>
>
>
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
Quote:
',img_<?=$recordCount?>.width
>+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
><?
> }
> echo " <img
>>
>
>
>
src='images/certs/".$certImage[$dataArray['certificate']].".gif'><BR>".$data
Quote:
Quote:
Quote:
Array['title'];
>?>
> </td>
> <td width="4">&nbsp;</td>
> <td><b>Released</b><br><?=$dataArray['year']?><br>
> <b>Duration</b><br><?=$dataArray['duration']?><br>
> <b>Rating</b><br><img alt="Rating:
><?=$dataArray['rating']/2?>"
>align="absmiddle"
>src="images/ratings/pips<?=$dataArray['rating']?>.gif"></td>
> <td width="4">&nbsp;</td>
><?
> $recordCount++;
> }
>?>
> </tr>
><?
> }
>}
>----------------------------------
>>
>>
>"Ian Davies" <iandan.dav@virgin.netwrote in message
>news:j3wxg.1067$u4.703@newsfe3-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, so
I
Quote:
Quote:
Quote:
have
extracted the records into hiddenfield, textareas, dropdown
list
and
checkbox so that they can make changes.
I named these elements as arrays and wish to run an sql to
take
Quote:
Quote:
Quote:
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
>
>
************************************************** ********************
Quote:
Quote:
Quote:
<form action="commentselect.php" method="post"
enctype="multipart/form-data"
name="UpdateComments">
<table width="100%" border="0" cellpadding="0"
cellspacing="2"
Quote:
Quote:
Quote:
bgcolor="#FFFFFF">
<tr align="center" class="ListHeading">
<td width="20%" height="31">Category</td>
<td width="60%" height="31">Comment</td>
<td width="10%" height="31">Share</td>
</tr>
<tr class="BodyText">
<?php
while($row =& mysql_fetch_array($commentresults)) {
extract($row);
>
if ($i%2) {
$class = 'row1';
echo "<TR bgcolor=\"#CCCCCC\">\n";
>
} else {
$class = 'row2';
echo "<TR bgcolor=\"white\">\n";
}
$i += 1;
?>
<td width="20%" align="left" class="bodytext"><select
name="category[]" style="WIDTH: 90%">
<option value="<?php echo $row['TypeID']; ?>"><?php echo
$row['typedesc'];
?></option>
<?php
$commenttype = mysql_query("SELECT * FROM commenttype WHERE
username
=
'$username'");
if (!$commenttype) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
while($row1 =& mysql_fetch_array($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
Quote:
Quote:
Quote:
$commindex;
?>"></td>
<td width="60%" align="left" class="bodytext">
<textarea
Quote:
name="comm[]" rows="2" style="WIDTH: 99%"><?php echo
$comment;
Quote:
Quote:
Quote:
?></textarea></td>
<td width="10%" align="center" class="bodytext"><input
type="checkbox"
name="avail[]" value="checkbox" <?php share($available); ?>>
</td>
</tr>
<?php
}
?>
</table>
</form>
>
************************************************** **********
>
>
>>
>>
>
>
>>
>>
>
>


>
>
>
>

PSI_Orion
Guest
 
Posts: n/a
#11: Jul 27 '06

re: Using arrays to take records from a html table and update database


OK, take a look now. I have deliberately deleted IDs 3, 7 and 8 to show it
matches the necessary ID of all found items.

http://www.psiss.com/dummy

Chris
"Ian Davies" <iandan.dav@virgin.netwrote in message
news:357yg.26$WY2.16@newsfe3-gui.ntli.net...
Quote:
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 changes
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 be
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.comwrote in message
news:aE4yg.68433$sz1.47146@newsfe6-gui.ntli.net...
Quote:
>Take a look at http://www.psiss.com/dummy to see if I'm on the right
lines.
Quote:
>Obviously it's not nicely formatted and the "Update" checkboxes would be
>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 more
but
Quote:
>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@virgin.netwrote in message
>news:KL2yg.63521$Z61.2758@newsfe4-win.ntli.net...
Quote:
'....and a hidden field to contain...'
SHOULD READ
'....and I also have a hidden field that contains...'
>
>
ian
>
>
"Ian Davies" <iandan.dav@virgin.netwrote in message
news:EJ2yg.63520$Z61.54928@newsfe4-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
Quote:
Quote:
in
>a loop with an sql update. But Im lost as to how to create and use the
>arrays appropriately
>>
>Cheers
>Ian
>also I greatly appreciate your assistance
>>
>>
>"PSI_Orion" <orion@psiss.comwrote in message
>news:e71yg.46974$1g.21477@newsfe1-win.ntli.net...
I'm presuming comment is the textbox (or do you use textarea),
category
Quote:
Quote:
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@virgin.netwrote in message
news:Q9%xg.52408$IU2.3744@newsfe2-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
Quote:
Quote:
dropdown list and a tick box which are in the other columns.
Ian
>
>
"PSI_Orion" <orion@psiss.comwrote in message
news:MQSxg.1434$v4.793@newsfe3-win.ntli.net...
>Yes, that explains it much better. Which field is it you are
trying
Quote:
Quote:
to
>amend? Is it a simple yes/no type field? If so then you need to
>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 try
>and
>explain how I would approach it.
>>
>Regards
>>
>PSI_Orion
>>
>"Ian Davies" <iandan.dav@virgin.netwrote in message
>news:BwPxg.46899$1g.19898@newsfe1-win.ntli.net...
Thanks for the reply
The problem Im having isnt creating a table with the records in
it.
That
works fine. Im trying to find a way where the users can modify
the
Quote:
Quote:
records
in a table and they are all updated in one go. I thought using
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 to
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
Quote:
Quote:
accordingly
>
Hope this explains it better
>
Ian
>
"PSI_Orion" <orion@psiss.comwrote in message
news:uFIxg.62841$sz1.6724@newsfe6-gui.ntli.net...
>If I understand you correctly, the way I would do it is the
same
Quote:
Quote:
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
Quote:
Quote:
>while
loop
>and increment the naming field using the i variable you use,
ie:
Quote:
Quote:
>"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($allRecords 0)
>{
> $recordCount = 0;
> while($recordCount < $allRecords)
> {
> if(($recordCount / 2) % 2 == 1)
> {
>?>
> <tr align="center" class="tr_even">
><?
> }
> else
> {
>?>
> <tr align="center" class="tr_odd">
><?
> }
> for($colCount = 0; $colCount < 2 && $recordCount <
$allRecords;
Quote:
Quote:
>$colCount++)
> {
> $dataArray = mysql_fetch_array($result);
> $dataArray['starring'] =
str_replace("\r","<BR>",$dataArray['starring']);
> $dataArray['synopsis'] =
str_replace("\r","<BR>",$dataArray['synopsis']);
> $dataArray['duration'] =
>date('H:i',strtotime($dataArray['duration']));
>?>
> <td background="images/barSilver.jpg"
width="30"><?=($recordCount
>+
>1)?></td>
> <td width="4">&nbsp;</td>
> <td>
> <div class="div_info" style="position: absolute; width:
400px;
>z-index: 1; visibility: hidden;"
id="infoLayer_<?=$recordCount?>"
Quote:
Quote:
>>
>
>
>>
>
align="left"><b><u><?=$dataArray['title']?></u></b><p><u>Starring:</u><br><i
Quote:
Quote:
>>
>
>>
>>
Quote:
>>>>><?=$dataArray['starring']?></i></p><p><?=$dataArray['synopsis']?></p></d
i
Quote:
Quote:
>v
>>
><?
> if($dataArray['dvd_image'] == "None")
> {
>?>
> <img id="img_<?=$recordCount?>" width="50" height="70"
>src="images/dvds/none_small.jpg"
>>
>
>
>>
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
',img_<?=$recordCount?>.width
>+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
><?
> }
> else
> {
>?>
> <img id="img_<?=$recordCount?>" width="50" height="70"
>src="images/dvds/<?=$dataArray['dvd_image']?>"
>>
>
>
>>
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
',img_<?=$recordCount?>.width
>+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
><?
> }
> echo " <img
>>
>
>
>>
>
src='images/certs/".$certImage[$dataArray['certificate']].".gif'><BR>".$data
Quote:
Quote:
Array['title'];
>?>
> </td>
> <td width="4">&nbsp;</td>
> <td><b>Released</b><br><?=$dataArray['year']?><br>
> <b>Duration</b><br><?=$dataArray['duration']?><br>
> <b>Rating</b><br><img alt="Rating:
><?=$dataArray['rating']/2?>"
>align="absmiddle"
>src="images/ratings/pips<?=$dataArray['rating']?>.gif"></td>
> <td width="4">&nbsp;</td>
><?
> $recordCount++;
> }
>?>
> </tr>
><?
> }
>}
>----------------------------------
>>
>>
>"Ian Davies" <iandan.dav@virgin.netwrote in message
>news:j3wxg.1067$u4.703@newsfe3-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, so
I
Quote:
Quote:
>have
extracted the records into hiddenfield, textareas, dropdown
list
>and
checkbox so that they can make changes.
I named these elements as arrays and wish to run an sql to
take
Quote:
Quote:
>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
>
>
************************************************** ********************
Quote:
Quote:
<form action="commentselect.php" method="post"
enctype="multipart/form-data"
name="UpdateComments">
<table width="100%" border="0" cellpadding="0"
cellspacing="2"
Quote:
Quote:
bgcolor="#FFFFFF">
<tr align="center" class="ListHeading">
<td width="20%" height="31">Category</td>
<td width="60%" height="31">Comment</td>
<td width="10%" height="31">Share</td>
</tr>
<tr class="BodyText">
<?php
while($row =& mysql_fetch_array($commentresults)) {
extract($row);
>
if ($i%2) {
$class = 'row1';
echo "<TR bgcolor=\"#CCCCCC\">\n";
>
} else {
$class = 'row2';
echo "<TR bgcolor=\"white\">\n";
}
$i += 1;
?>
<td width="20%" align="left" class="bodytext"><select
name="category[]" style="WIDTH: 90%">
<option value="<?php echo $row['TypeID']; ?>"><?php echo
$row['typedesc'];
?></option>
<?php
$commenttype = mysql_query("SELECT * FROM commenttype WHERE
>username
=
'$username'");
if (!$commenttype) {
exit('<p>Error performing query: ' . mysql_error() .
'</p>');
}
while($row1 =& mysql_fetch_array($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
Quote:
Quote:
$commindex;
?>"></td>
<td width="60%" align="left" class="bodytext">
<textarea
name="comm[]" rows="2" style="WIDTH: 99%"><?php echo
$comment;
Quote:
Quote:
?></textarea></td>
<td width="10%" align="center" class="bodytext"><input
type="checkbox"
name="avail[]" value="checkbox" <?php share($available); ?>>
</td>
</tr>
<?php
}
?>
</table>
</form>
>
************************************************** **********
>
>
>>
>>
>
>
>>
>>
>
>
>
>
>>
>>
>
>
>>
>>
>
>

PSI_Orion
Guest
 
Posts: n/a
#12: Jul 27 '06

re: Using arrays to take records from a html table and update database


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@virgin.netwrote in message
news:357yg.26$WY2.16@newsfe3-gui.ntli.net...
Quote:
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 changes
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 be
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.comwrote in message
news:aE4yg.68433$sz1.47146@newsfe6-gui.ntli.net...
Quote:
>Take a look at http://www.psiss.com/dummy to see if I'm on the right
lines.
Quote:
>Obviously it's not nicely formatted and the "Update" checkboxes would be
>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 more
but
Quote:
>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@virgin.netwrote in message
>news:KL2yg.63521$Z61.2758@newsfe4-win.ntli.net...
Quote:
'....and a hidden field to contain...'
SHOULD READ
'....and I also have a hidden field that contains...'
>
>
ian
>
>
"Ian Davies" <iandan.dav@virgin.netwrote in message
news:EJ2yg.63520$Z61.54928@newsfe4-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
Quote:
Quote:
in
>a loop with an sql update. But Im lost as to how to create and use the
>arrays appropriately
>>
>Cheers
>Ian
>also I greatly appreciate your assistance
>>
>>
>"PSI_Orion" <orion@psiss.comwrote in message
>news:e71yg.46974$1g.21477@newsfe1-win.ntli.net...
I'm presuming comment is the textbox (or do you use textarea),
category
Quote:
Quote:
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@virgin.netwrote in message
news:Q9%xg.52408$IU2.3744@newsfe2-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
Quote:
Quote:
dropdown list and a tick box which are in the other columns.
Ian
>
>
"PSI_Orion" <orion@psiss.comwrote in message
news:MQSxg.1434$v4.793@newsfe3-win.ntli.net...
>Yes, that explains it much better. Which field is it you are
trying
Quote:
Quote:
to
>amend? Is it a simple yes/no type field? If so then you need to
>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 try
>and
>explain how I would approach it.
>>
>Regards
>>
>PSI_Orion
>>
>"Ian Davies" <iandan.dav@virgin.netwrote in message
>news:BwPxg.46899$1g.19898@newsfe1-win.ntli.net...
Thanks for the reply
The problem Im having isnt creating a table with the records in
it.
That
works fine. Im trying to find a way where the users can modify
the
Quote:
Quote:
records
in a table and they are all updated in one go. I thought using
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 to
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
Quote:
Quote:
accordingly
>
Hope this explains it better
>
Ian
>
"PSI_Orion" <orion@psiss.comwrote in message
news:uFIxg.62841$sz1.6724@newsfe6-gui.ntli.net...
>If I understand you correctly, the way I would do it is the
same
Quote:
Quote:
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
Quote:
Quote:
>while
loop
>and increment the naming field using the i variable you use,
ie:
Quote:
Quote:
>"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($allRecords 0)
>{
> $recordCount = 0;
> while($recordCount < $allRecords)
> {
> if(($recordCount / 2) % 2 == 1)
> {
>?>
> <tr align="center" class="tr_even">
><?
> }
> else
> {
>?>
> <tr align="center" class="tr_odd">
><?
> }
> for($colCount = 0; $colCount < 2 && $recordCount <
$allRecords;
Quote:
Quote:
>$colCount++)
> {
> $dataArray = mysql_fetch_array($result);
> $dataArray['starring'] =
str_replace("\r","<BR>",$dataArray['starring']);
> $dataArray['synopsis'] =
str_replace("\r","<BR>",$dataArray['synopsis']);
> $dataArray['duration'] =
>date('H:i',strtotime($dataArray['duration']));
>?>
> <td background="images/barSilver.jpg"
width="30"><?=($recordCount
>+
>1)?></td>
> <td width="4">&nbsp;</td>
> <td>
> <div class="div_info" style="position: absolute; width:
400px;
>z-index: 1; visibility: hidden;"
id="infoLayer_<?=$recordCount?>"
Quote:
Quote:
>>
>
>
>>
>
align="left"><b><u><?=$dataArray['title']?></u></b><p><u>Starring:</u><br><i
Quote:
Quote:
>>
>
>>
>>
Quote:
>>>>><?=$dataArray['starring']?></i></p><p><?=$dataArray['synopsis']?></p></d
i
Quote:
Quote:
>v
>>
><?
> if($dataArray['dvd_image'] == "None")
> {
>?>
> <img id="img_<?=$recordCount?>" width="50" height="70"
>src="images/dvds/none_small.jpg"
>>
>
>
>>
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
',img_<?=$recordCount?>.width
>+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
><?
> }
> else
> {
>?>
> <img id="img_<?=$recordCount?>" width="50" height="70"
>src="images/dvds/<?=$dataArray['dvd_image']?>"
>>
>
>
>>
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
',img_<?=$recordCount?>.width
>+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
><?
> }
> echo " <img
>>
>
>
>>
>
src='images/certs/".$certImage[$dataArray['certificate']].".gif'><BR>".$data
Quote:
Quote:
Array['title'];
>?>
> </td>
> <td width="4">&nbsp;</td>
> <td><b>Released</b><br><?=$dataArray['year']?><br>
> <b>Duration</b><br><?=$dataArray['duration']?><br>
> <b>Rating</b><br><img alt="Rating:
><?=$dataArray['rating']/2?>"
>align="absmiddle"
>src="images/ratings/pips<?=$dataArray['rating']?>.gif"></td>
> <td width="4">&nbsp;</td>
><?
> $recordCount++;
> }
>?>
> </tr>
><?
> }
>}
>----------------------------------
>>
>>
>"Ian Davies" <iandan.dav@virgin.netwrote in message
>news:j3wxg.1067$u4.703@newsfe3-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, so
I
Quote:
Quote:
>have
extracted the records into hiddenfield, textareas, dropdown
list
>and
checkbox so that they can make changes.
I named these elements as arrays and wish to run an sql to
take
Quote:
Quote:
>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
>
>
************************************************** ********************
Quote:
Quote:
<form action="commentselect.php" method="post"
enctype="multipart/form-data"
name="UpdateComments">
<table width="100%" border="0" cellpadding="0"
cellspacing="2"
Quote:
Quote:
bgcolor="#FFFFFF">
<tr align="center" class="ListHeading">
<td width="20%" height="31">Category</td>
<td width="60%" height="31">Comment</td>
<td width="10%" height="31">Share</td>
</tr>
<tr class="BodyText">
<?php
while($row =& mysql_fetch_array($commentresults)) {
extract($row);
>
if ($i%2) {
$class = 'row1';
echo "<TR bgcolor=\"#CCCCCC\">\n";
>
} else {
$class = 'row2';
echo "<TR bgcolor=\"white\">\n";
}
$i += 1;
?>
<td width="20%" align="left" class="bodytext"><select
name="category[]" style="WIDTH: 90%">
<option value="<?php echo $row['TypeID']; ?>"><?php echo
$row['typedesc'];
?></option>
<?php
$commenttype = mysql_query("SELECT * FROM commenttype WHERE
>username
=
'$username'");
if (!$commenttype) {
exit('<p>Error performing query: ' . mysql_error() .
'</p>');
}
while($row1 =& mysql_fetch_array($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
Quote:
Quote:
$commindex;
?>"></td>
<td width="60%" align="left" class="bodytext">
<textarea
name="comm[]" rows="2" style="WIDTH: 99%"><?php echo
$comment;
Quote:
Quote:
?></textarea></td>
<td width="10%" align="center" class="bodytext"><input
type="checkbox"
name="avail[]" value="checkbox" <?php share($available); ?>>
</td>
</tr>
<?php
}
?>
</table>
</form>
>
************************************************** **********
>
>
>>
>>
>
>
>>
>>
>
>
>
>
>>
>>
>
>
>>
>>
>
>

Ian Davies
Guest
 
Posts: n/a
#13: Jul 27 '06

re: Using arrays to take records from a html table and update database


yes
I think that is what im looking for but your code isnt visible
Did you use arrays?


"PSI_Orion" <orion@psiss.comwrote in message
news:ZN9yg.71$ts3.49@newsfe2-gui.ntli.net...
Quote:
OK, take a look now. I have deliberately deleted IDs 3, 7 and 8 to show
it
Quote:
matches the necessary ID of all found items.
>
http://www.psiss.com/dummy
>
Chris
"Ian Davies" <iandan.dav@virgin.netwrote in message
news:357yg.26$WY2.16@newsfe3-gui.ntli.net...
Quote:
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
changes
Quote:
Quote:
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
be
Quote:
Quote:
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.comwrote in message
news:aE4yg.68433$sz1.47146@newsfe6-gui.ntli.net...
Quote:
Take a look at http://www.psiss.com/dummy to see if I'm on the right
lines.
Quote:
Obviously it's not nicely formatted and the "Update" checkboxes would
be
Quote:
Quote:
Quote:
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
more
Quote:
Quote:
but
Quote:
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@virgin.netwrote in message
news:KL2yg.63521$Z61.2758@newsfe4-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@virgin.netwrote in message
news:EJ2yg.63520$Z61.54928@newsfe4-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
Quote:
in
a loop with an sql update. But Im lost as to how to create and use
the
Quote:
Quote:
Quote:
arrays appropriately
>
Cheers
Ian
also I greatly appreciate your assistance
>
>
"PSI_Orion" <orion@psiss.comwrote in message
news:e71yg.46974$1g.21477@newsfe1-win.ntli.net...
I'm presuming comment is the textbox (or do you use textarea),
category
Quote:
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@virgin.netwrote in message
news:Q9%xg.52408$IU2.3744@newsfe2-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
Quote:
dropdown list and a tick box which are in the other columns.
Ian
>
>
"PSI_Orion" <orion@psiss.comwrote in message
news:MQSxg.1434$v4.793@newsfe3-win.ntli.net...
>Yes, that explains it much better. Which field is it you are
trying
Quote:
to
>amend? Is it a simple yes/no type field? If so then you need
to
Quote:
Quote:
Quote:
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
try
Quote:
Quote:
Quote:
>and
>explain how I would approach it.
>>
>Regards
>>
>PSI_Orion
>>
>"Ian Davies" <iandan.dav@virgin.netwrote in message
>news:BwPxg.46899$1g.19898@newsfe1-win.ntli.net...
Thanks for the reply
The problem Im having isnt creating a table with the records
in
Quote:
Quote:
Quote:
it.
That
works fine. Im trying to find a way where the users can
modify
Quote:
Quote:
the
Quote:
records
in a table and they are all updated in one go. I thought
using
Quote:
Quote:
Quote:
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
to
Quote:
Quote:
Quote:
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
Quote:
accordingly
>
Hope this explains it better
>
Ian
>
"PSI_Orion" <orion@psiss.comwrote in message
news:uFIxg.62841$sz1.6724@newsfe6-gui.ntli.net...
>If I understand you correctly, the way I would do it is the
same
Quote:
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
Quote:
while
loop
>and increment the naming field using the i variable you use,
ie:
Quote:
>"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($allRecords 0)
>{
> $recordCount = 0;
> while($recordCount < $allRecords)
> {
> if(($recordCount / 2) % 2 == 1)
> {
>?>
> <tr align="center" class="tr_even">
><?
> }
> else
> {
>?>
> <tr align="center" class="tr_odd">
><?
> }
> for($colCount = 0; $colCount < 2 && $recordCount <
$allRecords;
Quote:
>$colCount++)
> {
> $dataArray = mysql_fetch_array($result);
> $dataArray['starring'] =
str_replace("\r","<BR>",$dataArray['starring']);
> $dataArray['synopsis'] =
str_replace("\r","<BR>",$dataArray['synopsis']);
> $dataArray['duration'] =
>date('H:i',strtotime($dataArray['duration']));
>?>
> <td background="images/barSilver.jpg"
width="30"><?=($recordCount
+
>1)?></td>
> <td width="4">&nbsp;</td>
> <td>
> <div class="div_info" style="position: absolute;
width:
Quote:
Quote:
Quote:
400px;
>z-index: 1; visibility: hidden;"
id="infoLayer_<?=$recordCount?>"
Quote:
>>
>
>
>
align="left"><b><u><?=$dataArray['title']?></u></b><p><u>Starring:</u><br><i
Quote:
Quote:
Quote:
>>

>
>
>
Quote:
Quote:
>>>>><?=$dataArray['starring']?></i></p><p><?=$dataArray['synopsis']?></p></
d
Quote:
Quote:
i
Quote:
v
>>
><?
> if($dataArray['dvd_image'] == "None")
> {
>?>
> <img id="img_<?=$recordCount?>" width="50" height="70"
>src="images/dvds/none_small.jpg"
>>
>
>
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
Quote:
',img_<?=$recordCount?>.width
>+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
><?
> }
> else
> {
>?>
> <img id="img_<?=$recordCount?>" width="50" height="70"
>src="images/dvds/<?=$dataArray['dvd_image']?>"
>>
>
>
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
Quote:
',img_<?=$recordCount?>.width
>+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
><?
> }
> echo " <img
>>
>
>
>
src='images/certs/".$certImage[$dataArray['certificate']].".gif'><BR>".$data
Quote:
Quote:
Quote:
Array['title'];
>?>
> </td>
> <td width="4">&nbsp;</td>
> <td><b>Released</b><br><?=$dataArray['year']?><br>
> <b>Duration</b><br><?=$dataArray['duration']?><br>
> <b>Rating</b><br><img alt="Rating:
><?=$dataArray['rating']/2?>"
>align="absmiddle"
>src="images/ratings/pips<?=$dataArray['rating']?>.gif"></td>
> <td width="4">&nbsp;</td>
><?
> $recordCount++;
> }
>?>
> </tr>
><?
> }
>}
>----------------------------------
>>
>>
>"Ian Davies" <iandan.dav@virgin.netwrote in message
>news:j3wxg.1067$u4.703@newsfe3-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,
so
Quote:
Quote:
I
Quote:
have
extracted the records into hiddenfield, textareas,
dropdown
Quote:
Quote:
Quote:
list
and
checkbox so that they can make changes.
I named these elements as arrays and wish to run an sql to
take
Quote:
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
>
>
************************************************** ********************
Quote:
<form action="commentselect.php" method="post"
enctype="multipart/form-data"
name="UpdateComments">
<table width="100%" border="0" cellpadding="0"
cellspacing="2"
Quote:
bgcolor="#FFFFFF">
<tr align="center" class="ListHeading">
<td width="20%" height="31">Category</td>
<td width="60%" height="31">Comment</td>
<td width="10%" height="31">Share</td>
</tr>
<tr class="BodyText">
<?php
while($row =& mysql_fetch_array($commentresults)) {
extract($row);
>
if ($i%2) {
$class = 'row1';
echo "<TR bgcolor=\"#CCCCCC\">\n";
>
} else {
$class = 'row2';
echo "<TR bgcolor=\"white\">\n";
}
$i += 1;
?>
<td width="20%" align="left" class="bodytext"><select
name="category[]" style="WIDTH: 90%">
<option value="<?php echo $row['TypeID']; ?>"><?php echo
$row['typedesc'];
?></option>
<?php
$commenttype = mysql_query("SELECT * FROM commenttype
WHERE
Quote:
Quote:
Quote:
username
=
'$username'");
if (!$commenttype) {
exit('<p>Error performing query: ' . mysql_error() .
'</p>');
}
while($row1 =& mysql_fetch_array($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
Quote:
$commindex;
?>"></td>
<td width="60%" align="left" class="bodytext">
<textarea
name="comm[]" rows="2" style="WIDTH: 99%"><?php echo
$comment;
Quote:
?></textarea></td>
<td width="10%" align="center"
class="bodytext"><input
Quote:
Quote:
Quote:
type="checkbox"
name="avail[]" value="checkbox" <?php share($available);
?>>
Quote:
Quote:
Quote:
</td>
</tr>
<?php
}
?>
</table>
</form>
>
>
************************************************** **********
Quote:
Quote:
Quote:
>
>
>>
>>
>
>
>>
>>
>
>


>
>


>
>
>
>

Ian Davies
Guest
 
Posts: n/a
#14: Jul 28 '06

re: Using arrays to take records from a html table and update database


Cheers.
that would be great
Ian

"PSI_Orion" <orion@psiss.comwrote in message
news:vnbyg.47047$1g.3775@newsfe1-win.ntli.net...
Quote:
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@virgin.netwrote in message
news:357yg.26$WY2.16@newsfe3-gui.ntli.net...
Quote:
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
changes
Quote:
Quote:
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
be
Quote:
Quote:
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.comwrote in message
news:aE4yg.68433$sz1.47146@newsfe6-gui.ntli.net...
Quote:
Take a look at http://www.psiss.com/dummy to see if I'm on the right
lines.
Quote:
Obviously it's not nicely formatted and the "Update" checkboxes would
be
Quote:
Quote:
Quote:
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
more
Quote:
Quote:
but
Quote:
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@virgin.netwrote in message
news:KL2yg.63521$Z61.2758@newsfe4-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@virgin.netwrote in message
news:EJ2yg.63520$Z61.54928@newsfe4-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
Quote:
in
a loop with an sql update. But Im lost as to how to create and use
the
Quote:
Quote:
Quote:
arrays appropriately
>
Cheers
Ian
also I greatly appreciate your assistance
>
>
"PSI_Orion" <orion@psiss.comwrote in message
news:e71yg.46974$1g.21477@newsfe1-win.ntli.net...
I'm presuming comment is the textbox (or do you use textarea),
category
Quote:
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@virgin.netwrote in message
news:Q9%xg.52408$IU2.3744@newsfe2-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
Quote:
dropdown list and a tick box which are in the other columns.
Ian
>
>
"PSI_Orion" <orion@psiss.comwrote in message
news:MQSxg.1434$v4.793@newsfe3-win.ntli.net...
>Yes, that explains it much better. Which field is it you are
trying
Quote:
to
>amend? Is it a simple yes/no type field? If so then you need
to
Quote:
Quote:
Quote:
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
try
Quote:
Quote:
Quote:
>and
>explain how I would approach it.
>>
>Regards
>>
>PSI_Orion
>>
>"Ian Davies" <iandan.dav@virgin.netwrote in message
>news:BwPxg.46899$1g.19898@newsfe1-win.ntli.net...
Thanks for the reply
The problem Im having isnt creating a table with the records
in
Quote:
Quote:
Quote:
it.
That
works fine. Im trying to find a way where the users can
modify
Quote:
Quote:
the
Quote:
records
in a table and they are all updated in one go. I thought
using
Quote:
Quote:
Quote:
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
to
Quote:
Quote:
Quote:
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
Quote:
accordingly
>
Hope this explains it better
>
Ian
>
"PSI_Orion" <orion@psiss.comwrote in message
news:uFIxg.62841$sz1.6724@newsfe6-gui.ntli.net...
>If I understand you correctly, the way I would do it is the
same
Quote:
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
Quote:
while
loop
>and increment the naming field using the i variable you use,
ie:
Quote:
>"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($allRecords 0)
>{
> $recordCount = 0;
> while($recordCount < $allRecords)
> {
> if(($recordCount / 2) % 2 == 1)
> {
>?>
> <tr align="center" class="tr_even">
><?
> }
> else
> {
>?>
> <tr align="center" class="tr_odd">
><?
> }
> for($colCount = 0; $colCount < 2 && $recordCount <
$allRecords;
Quote:
>$colCount++)
> {
> $dataArray = mysql_fetch_array($result);
> $dataArray['starring'] =
str_replace("\r","<BR>",$dataArray['starring']);
> $dataArray['synopsis'] =
str_replace("\r","<BR>",$dataArray['synopsis']);
> $dataArray['duration'] =
>date('H:i',strtotime($dataArray['duration']));
>?>
> <td background="images/barSilver.jpg"
width="30"><?=($recordCount
+
>1)?></td>
> <td width="4">&nbsp;</td>
> <td>
> <div class="div_info" style="position: absolute;
width:
Quote:
Quote:
Quote:
400px;
>z-index: 1; visibility: hidden;"
id="infoLayer_<?=$recordCount?>"
Quote:
>>
>
>
>
align="left"><b><u><?=$dataArray['title']?></u></b><p><u>Starring:</u><br><i
Quote:
Quote:
Quote:
>>

>
>
>
Quote:
Quote:
>>>>><?=$dataArray['starring']?></i></p><p><?=$dataArray['synopsis']?></p></
d
Quote:
Quote:
i
Quote:
v
>>
><?
> if($dataArray['dvd_image'] == "None")
> {
>?>
> <img id="img_<?=$recordCount?>" width="50" height="70"
>src="images/dvds/none_small.jpg"
>>
>
>
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
Quote:
',img_<?=$recordCount?>.width
>+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
><?
> }
> else
> {
>?>
> <img id="img_<?=$recordCount?>" width="50" height="70"
>src="images/dvds/<?=$dataArray['dvd_image']?>"
>>
>
>
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
Quote:
',img_<?=$recordCount?>.width
>+ 5,5)" onmouseout="popHide('infoLayer_<?=$recordCount?>') ">
><?
> }
> echo " <img
>>
>
>
>
src='images/certs/".$certImage[$dataArray['certificate']].".gif'><BR>".$data
Quote:
Quote:
Quote:
Array['title'];
>?>
> </td>
> <td width="4">&nbsp;</td>
> <td><b>Released</b><br><?=$dataArray['year']?><br>
> <b>Duration</b><br><?=$dataArray['duration']?><br>
> <b>Rating</b><br><img alt="Rating:
><?=$dataArray['rating']/2?>"
>align="absmiddle"
>src="images/ratings/pips<?=$dataArray['rating']?>.gif"></td>
> <td width="4">&nbsp;</td>
><?
> $recordCount++;
> }
>?>
> </tr>
><?
> }
>}
>----------------------------------
>>
>>
>"Ian Davies" <iandan.dav@virgin.netwrote in message
>news:j3wxg.1067$u4.703@newsfe3-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,
so
Quote:
Quote:
I
Quote:
have
extracted the records into hiddenfield, textareas,
dropdown
Quote:
Quote:
Quote:
list
and
checkbox so that they can make changes.
I named these elements as arrays and wish to run an sql to
take
Quote:
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
>
>
************************************************** ********************
Quote:
<form action="commentselect.php" method="post"
enctype="multipart/form-data"
name="UpdateComments">
<table width="100%" border="0" cellpadding="0"
cellspacing="2"
Quote:
bgcolor="#FFFFFF">
<tr align="center" class="ListHeading">
<td width="20%" height="31">Category</td>
<td width="60%" height="31">Comment</td>
<td width="10%" height="31">Share</td>
</tr>
<tr class="BodyText">
<?php
while($row =& mysql_fetch_array($commentresults)) {
extract($row);
>
if ($i%2) {
$class = 'row1';
echo "<TR bgcolor=\"#CCCCCC\">\n";
>
} else {
$class = 'row2';
echo "<TR bgcolor=\"white\">\n";
}
$i += 1;
?>
<td width="20%" align="left" class="bodytext"><select
name="category[]" style="WIDTH: 90%">
<option value="<?php echo $row['TypeID']; ?>"><?php echo
$row['typedesc'];
?></option>
<?php
$commenttype = mysql_query("SELECT * FROM commenttype
WHERE
Quote:
Quote:
Quote:
username
=
'$username'");
if (!$commenttype) {
exit('<p>Error performing query: ' . mysql_error() .
'</p>');
}
while($row1 =& mysql_fetch_array($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
Quote:
$commindex;
?>"></td>
<td width="60%" align="left" class="bodytext">
<textarea
name="comm[]" rows="2" style="WIDTH: 99%"><?php echo
$comment;
Quote:
?></textarea></td>
<td width="10%" align="center"
class="bodytext"><input
Quote:
Quote:
Quote:
type="checkbox"
name="avail[]" value="checkbox" <?php share($available);
?>>
Quote:
Quote:
Quote:
</td>
</tr>
<?php
}
?>
</table>
</form>
>
>
************************************************** **********
Quote:
Quote:
Quote:
>
>
>>
>>
>
>
>>
>>
>
>


>
>


>
>
>
>

PSI_Orion
Guest
 
Posts: n/a
#15: Jul 29 '06

re: Using arrays to take records from a html table and update database


File sent.

"Ian Davies" <iandan.dav@virgin.netwrote in message
news:Q0oyg.57825$ST2.5343@newsfe5-win.ntli.net...
Quote:
Cheers.
that would be great
Ian
>
"PSI_Orion" <orion@psiss.comwrote in message
news:vnbyg.47047$1g.3775@newsfe1-win.ntli.net...
Quote:
>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@virgin.netwrote in message
>news:357yg.26$WY2.16@newsfe3-gui.ntli.net...
Quote:
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
changes
Quote:
Quote:
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
be
Quote:
Quote:
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.comwrote in message
news:aE4yg.68433$sz1.47146@newsfe6-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
be
Quote:
Quote:
>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
more
Quote:
Quote:
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@virgin.netwrote in message
>news:KL2yg.63521$Z61.2758@newsfe4-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@virgin.netwrote in message
news:EJ2yg.63520$Z61.54928@newsfe4-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
the
Quote:
Quote:
>arrays appropriately
>>
>Cheers
>Ian
>also I greatly appreciate your assistance
>>
>>
>"PSI_Orion" <orion@psiss.comwrote in message
>news:e71yg.46974$1g.21477@newsfe1-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@virgin.netwrote in message
news:Q9%xg.52408$IU2.3744@newsfe2-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.comwrote in message
news:MQSxg.1434$v4.793@newsfe3-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
to
Quote:
Quote:
>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
try
Quote:
Quote:
>and
>explain how I would approach it.
>>
>Regards
>>
>PSI_Orion
>>
>"Ian Davies" <iandan.dav@virgin.netwrote in message
>news:BwPxg.46899$1g.19898@newsfe1-win.ntli.net...
Thanks for the reply
The problem Im having isnt creating a table with the records
in
Quote:
Quote:
it.
That
works fine. Im trying to find a way where the users can
modify
Quote:
Quote:
the
records
in a table and they are all updated in one go. I thought
using
Quote:
Quote:
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
to
Quote:
Quote:
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.comwrote in message
news:uFIxg.62841$sz1.6724@newsfe6-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($allRecords 0)
>{
> $recordCount = 0;
> while($recordCount < $allRecords)
> {
> if(($recordCount / 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_array($result);
> $dataArray['starring'] =
str_replace("\r","<BR>",$dataArray['starring']);
> $dataArray['synopsis'] =
str_replace("\r","<BR>",$dataArray['synopsis']);
> $dataArray['duration'] =
>date('H:i',strtotime($dataArray['duration']));
>?>
> <td background="images/barSilver.jpg"
width="30"><?=($recordCount
>+
>1)?></td>
> <td width="4">&nbsp;</td>
> <td>
> <div class="div_info" style="position: absolute;
width:
Quote:
Quote:
400px;
>z-index: 1; visibility: hidden;"
id="infoLayer_<?=$recordCount?>"
>>
>
>
>>
>
>
align="left"><b><u><?=$dataArray['title']?></u></b><p><u>Starring:</u><br><i
Quote:
Quote:
>>
>
>>
>>
>>
Quote:
>>>>>><?=$dataArray['starring']?></i></p><p><?=$dataArray['synopsis']?></p></
d
Quote:
Quote:
i
>v
>>
><?
> if($dataArray['dvd_image'] == "None")
> {
>?>
> <img id="img_<?=$recordCount?>" width="50" height="70"
>src="images/dvds/none_small.jpg"
>>
>
>
>>
>
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
',img_<?=$recordCount?>.width
>+ 5,5)"
>onmouseout="popHide('infoLayer_<?=$recordCount?>' )">
><?
> }
> else
> {
>?>
> <img id="img_<?=$recordCount?>" width="50" height="70"
>src="images/dvds/<?=$dataArray['dvd_image']?>"
>>
>
>
>>
>
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
',img_<?=$recordCount?>.width
>+ 5,5)"
>onmouseout="popHide('infoLayer_<?=$recordCount?>' )">
><?
> }
> echo " <img
>>
>
>
>>
>
>
src='images/certs/".$certImage[$dataArray['certificate']].".gif'><BR>".$data
Quote:
Quote:
Array['title'];
>?>
> </td>
> <td width="4">&nbsp;</td>
> <td><b>Released</b><br><?=$dataArray['year']?><br>
> <b>Duration</b><br><?=$dataArray['duration']?><br>
> <b>Rating</b><br><img alt="Rating:
><?=$dataArray['rating']/2?>"
>align="absmiddle"
>src="images/ratings/pips<?=$dataArray['rating']?>.gif"></td>
> <td width="4">&nbsp;</td>
><?
> $recordCount++;
> }
>?>
> </tr>
><?
> }
>}
>----------------------------------
>>
>>
>"Ian Davies" <iandan.dav@virgin.netwrote in message
>news:j3wxg.1067$u4.703@newsfe3-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,
so
Quote:
Quote:
I
>have
extracted the records into hiddenfield, textareas,
dropdown
Quote:
Quote:
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="commentselect.php" method="post"
enctype="multipart/form-data"
name="UpdateComments">
<table width="100%" border="0" cellpadding="0"
cellspacing="2"
bgcolor="#FFFFFF">
<tr align="center" class="ListHeading">
<td width="20%" height="31">Category</td>
<td width="60%" height="31">Comment</td>
<td width="10%" height="31">Share</td>
</tr>
<tr class="BodyText">
<?php
while($row =& mysql_fetch_array($commentresults)) {
extract($row);
>
if ($i%2) {
$class = 'row1';
echo "<TR bgcolor=\"#CCCCCC\">\n";
>
} else {
$class = 'row2';
echo "<TR bgcolor=\"white\">\n";
}
$i += 1;
?>
<td width="20%" align="left"
class="bodytext"><select
name="category[]" style="WIDTH: 90%">
<option value="<?php echo $row['TypeID']; ?>"><?php echo
$row['typedesc'];
?></option>
<?php
$commenttype = mysql_query("SELECT * FROM commenttype
WHERE
Quote:
Quote:
>username
=
'$username'");
if (!$commenttype) {
exit('<p>Error performing query: ' . mysql_error() .
'</p>');
}
while($row1 =& mysql_fetch_array($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"
class="bodytext"><input
Quote:
Quote:
type="checkbox"
name="avail[]" value="checkbox" <?php share($available);
?>>
Quote:
Quote:
</td>
</tr>
<?php
}
?>
</table>
</form>
>
>
************************************************** **********
Quote:
Quote:
>
>
>>
>>
>
>
>>
>>
>
>
>
>
>>
>>
>
>
>>
>>
>
>
>>
>>
>
>

PSI_Orion
Guest
 
Posts: n/a
#16: Jul 29 '06

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.comwrote in message
news:mexyg.3457$v4.1602@newsfe3-win.ntli.net...
Quote:
File sent.
>
"Ian Davies" <iandan.dav@virgin.netwrote in message
news:Q0oyg.57825$ST2.5343@newsfe5-win.ntli.net...
Quote:
>Cheers.
>that would be great
>Ian
>>
>"PSI_Orion" <orion@psiss.comwrote in message
>news:vnbyg.47047$1g.3775@newsfe1-win.ntli.net...
Quote:
>>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@virgin.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
>changes
Quote:
>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
>be
Quote:
>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.comwrote in message
>news:aE4yg.68433$sz1.47146@newsfe6-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
>be
Quote:
>>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
>more
Quote:
>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@virgin.netwrote in message
>>news:KL2yg.63521$Z61.2758@newsfe4-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@virgin.netwrote in message
>news:EJ2yg.63520$Z61.54928@newsfe4-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
>the
Quote:
>>arrays appropriately
>>>
>>Cheers
>>Ian
>>also I greatly appreciate your assistance
>>>
>>>
>>"PSI_Orion" <orion@psiss.comwrote in message
>>news:e71yg.46974$1g.21477@newsfe1-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@virgin.netwrote in message
>news:Q9%xg.52408$IU2.3744@newsfe2-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.comwrote in message
>news:MQSxg.1434$v4.793@newsfe3-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
>to
Quote:
>>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
>try
Quote:
>>and
>>explain how I would approach it.
>>>
>>Regards
>>>
>>PSI_Orion
>>>
>>"Ian Davies" <iandan.dav@virgin.netwrote in message
>>news:BwPxg.46899$1g.19898@newsfe1-win.ntli.net...
>Thanks for the reply
>The problem Im having isnt creating a table with the
>records
>in
Quote:
>it.
>That
>works fine. Im trying to find a way where the users can
>modify
Quote:
>the
>records
>in a table and they are all updated in one go. I thought
>using
Quote:
>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
>to
Quote:
>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.comwrote in message
>news:uFIxg.62841$sz1.6724@newsfe6-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($allRecords 0)
>>{
>> $recordCount = 0;
>> while($recordCount < $allRecords)
>> {
>> if(($recordCount / 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_array($result);
>> $dataArray['starring'] =
>str_replace("\r","<BR>",$dataArray['starring']);
>> $dataArray['synopsis'] =
>str_replace("\r","<BR>",$dataArray['synopsis']);
>> $dataArray['duration'] =
>>date('H:i',strtotime($dataArray['duration']));
>>?>
>> <td background="images/barSilver.jpg"
>width="30"><?=($recordCount
>>+
>>1)?></td>
>> <td width="4">&nbsp;</td>
>> <td>
>> <div class="div_info" style="position: absolute;
>width:
Quote:
>400px;
>>z-index: 1; visibility: hidden;"
>id="infoLayer_<?=$recordCount?>"
>>>
>>
>>
>>>
>>
>>
>align="left"><b><u><?=$dataArray['title']?></u></b><p><u>Starring:</u><br><i
Quote:
>>>
>>
>>>
>>>
>>>
>>>>>>><?=$dataArray['starring']?></i></p><p><?=$dataArray['synopsis']?></p></
>d
Quote:
>i
>>v
>>>
>><?
>> if($dataArray['dvd_image'] == "None")
>> {
>>?>
>> <img id="img_<?=$recordCount?>" width="50" height="70"
>>src="images/dvds/none_small.jpg"
>>>
>>
>>
>>>
>>
>>
>onmouseover="popShow(this,img_<?=$recordCount?>,' infoLayer_<?=$recordCount?>
Quote:
>',img_<?=$recordCount?>.width
>>+ 5,5)"
>>onmouseout="popHide('infoLayer_<?=$recordCount?> ')">
>><?
>> }
>> else
>> {
>>?>
>> <img id="img_<?=$recordCount?>" width="50" height="70"
>>src="images/dvds/<?=$dataArray['dvd_image']?>"
>>>
>>
>>
>>>
>>
>>
>onmouseover="popShow(this,img_<?=$recordCount?>,' infoLayer_<?=$recordCount?>
Quote:
>',img_<?=$recordCount?>.width
>>+ 5,5)"
>>onmouseout="popHide('infoLayer_<?=$recordCount?> ')">
>><?
>> }
>> echo " <img
>>>
>>
>>
>>>
>>
>>
>src='images/certs/".$certImage[$dataArray['certificate']].".gif'><BR>".$data
Quote:
>Array['title'];
>>?>
>> </td>
>> <td width="4">&nbsp;</td>
>> <td><b>Released</b><br><?=$dataArray['year']?><br>
>> <b>Duration</b><br><?=$dataArray['duration']?><br>
>> <b>Rating</b><br><img alt="Rating:
>><?=$dataArray['rating']/2?>"
>>align="absmiddle"
>>src="images/ratings/pips<?=$dataArray['rating']?>.gif"></td>
>> <td width="4">&nbsp;</td>
>><?
>> $recordCount++;
>> }
>>?>
>> </tr>
>><?
>> }
>>}
>>----------------------------------
>>>
>>>
>>"Ian Davies" <iandan.dav@virgin.netwrote in message
>>news:j3wxg.1067$u4.703@newsfe3-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,
>so
Quote:
>I
>>have
>extracted the records into hiddenfield, textareas,
>dropdown
Quote:
>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="commentselect.php" method="post"
>enctype="multipart/form-data"
>name="UpdateComments">
> <table width="100%" border="0" cellpadding="0"
>cellspacing="2"
>bgcolor="#FFFFFF">
> <tr align="center" class="ListHeading">
> <td width="20%" height="31">Category</td>
> <td width="60%" height="31">Comment</td>
> <td width="10%" height="31">Share</td>
> </tr>
> <tr class="BodyText">
> <?php
>while($row =& mysql_fetch_array($commentresults)) {
>extract($row);
>>
>if ($i%2) {
> $class = 'row1';
> echo "<TR bgcolor=\"#CCCCCC\">\n";
>>
>} else {
> $class = 'row2';
> echo "<TR bgcolor=\"white\">\n";
>}
>$i += 1;
>?>
> <td width="20%" align="left"
>class="bodytext"><select
>name="category[]" style="WIDTH: 90%">
><option value="<?php echo $row['TypeID']; ?>"><?php echo
>$row['typedesc'];
>?></option>
> <?php
>$commenttype = mysql_query("SELECT * FROM commenttype
>WHERE
Quote:
>>username
>=
>'$username'");
>if (!$commenttype) {
>exit('<p>Error performing query: ' . mysql_error() .
>'</p>');
>}
>while($row1 =& mysql_fetch_array($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"
>class="bodytext"><input
Quote:
>type="checkbox"
>name="avail[]" value="checkbox" <?php share($available);
>?>>
Quote:
></td>
> </tr>
> <?php
>}
>?>
> </table>
></form>
>>
>>
>************************************************* ***********
Quote:
>>
>>
>>>
>>>
>>
>>
>>>
>>>
>>
>>
>>
>>
>>>
>>>
>>
>>
>>>
>>>
>>
>>
>>>
>>>
>>
>>
>
>

Ian Davies
Guest
 
Posts: n/a
#17: Jul 29 '06

re: Using arrays to take records from a html table and update database


sorry
try
ianDOTdandavATvirginDOTnet

"PSI_Orion" <orion@psiss.comwrote in message
news:Orxyg.59928$ST2.54210@newsfe5-win.ntli.net...
Quote:
Well, it would have been if the email addy was correct...
>
"PSI_Orion" <orion@psiss.comwrote in message
news:mexyg.3457$v4.1602@newsfe3-win.ntli.net...
Quote:
File sent.

"Ian Davies" <iandan.dav@virgin.netwrote in message
news:Q0oyg.57825$ST2.5343@newsfe5-win.ntli.net...
Quote:
Cheers.
that would be great
Ian
>
"PSI_Orion" <orion@psiss.comwrote in message
news:vnbyg.47047$1g.3775@newsfe1-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@virgin.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
changes
to the comments and categories etc but would forget to tick the
update
Quote:
Quote:
Quote:
check
box. My solution was to update ALL the displayed records. this
wouldnt
Quote:
Quote:
Quote:
be
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
Quote:
Quote:
Quote:
planned to use to reference the correct record from the database
table
Quote:
Quote:
Quote:
>
ian
>
"PSI_Orion" <orion@psiss.comwrote in message
news:aE4yg.68433$sz1.47146@newsfe6-gui.ntli.net...
>Take a look at http://www.psiss.com/dummy to see if I'm on the
right
Quote:
Quote:
Quote:
lines.
>Obviously it's not nicely formatted and the "Update" checkboxes
would
Quote:
Quote:
Quote:
be
>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
more
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@virgin.netwrote in message
>news:KL2yg.63521$Z61.2758@newsfe4-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@virgin.netwrote in message
news:EJ2yg.63520$Z61.54928@newsfe4-win.ntli.net...
>Hello
>That is correct. also comment is a textarea. and a hidden field
to
Quote:
Quote:
Quote:
>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
Quote:
Quote:
Quote:
the
>arrays appropriately
>>
>Cheers
>Ian
>also I greatly appreciate your assistance
>>
>>
>"PSI_Orion" <orion@psiss.comwrote in message
>news:e71yg.46974$1g.21477@newsfe1-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@virgin.netwrote in message
news:Q9%xg.52408$IU2.3744@newsfe2-win.ntli.net...
Hi
I am trying to amend three fields all one text and two
integer
Quote:
Quote:
Quote:
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
Quote:
Quote:
Quote:
from
a
dropdown list and a tick box which are in the other columns.
Ian
>
>
"PSI_Orion" <orion@psiss.comwrote in message
news:MQSxg.1434$v4.793@newsfe3-win.ntli.net...
>Yes, that explains it much better. Which field is it you
are
Quote:
Quote:
Quote:
trying
to
>amend? Is it a simple yes/no type field? If so then you
>need
to
>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
Quote:
Quote:
Quote:
try
>and
>explain how I would approach it.
>>
>Regards
>>
>PSI_Orion
>>
>"Ian Davies" <iandan.dav@virgin.netwrote in message
>news:BwPxg.46899$1g.19898@newsfe1-win.ntli.net...
Thanks for the reply
The problem Im having isnt creating a table with the
records
in
it.
That
works fine. Im trying to find a way where the users can
modify
the
records
in a table and they are all updated in one go. I thought
using
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
Quote:
Quote:
Quote:
displated
>on
a
new page where it can be updated. But this requires the
user
to
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
Quote:
Quote:
Quote:
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.comwrote in message
news:uFIxg.62841$sz1.6724@newsfe6-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
Quote:
Quote:
Quote:
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
Quote:
Quote:
Quote:
database
code
>which you can view at "http:// mydvds . psiss . com"
>>
>------------------------------------------------------
>if($allRecords 0)
>{
> $recordCount = 0;
> while($recordCount < $allRecords)
> {
> if(($recordCount / 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_array($result);
> $dataArray['starring'] =
str_replace("\r","<BR>",$dataArray['starring']);
> $dataArray['synopsis'] =
str_replace("\r","<BR>",$dataArray['synopsis']);
> $dataArray['duration'] =
>date('H:i',strtotime($dataArray['duration']));
>?>
> <td background="images/barSilver.jpg"
width="30"><?=($recordCount
>+
>1)?></td>
> <td width="4">&nbsp;</td>
> <td>
> <div class="div_info" style="position: absolute;
width:
400px;
>z-index: 1; visibility: hidden;"
id="infoLayer_<?=$recordCount?>"
>>
>
>
>>
>
>
>
align="left"><b><u><?=$dataArray['title']?></u></b><p><u>Starring:</u><br><i
Quote:
Quote:
Quote:
>>
>
>>
>>
>>
>
Quote:
Quote:
>>>>>>><?=$dataArray['starring']?></i></p><p><?=$dataArray['synopsis']?></p>
</
Quote:
Quote:
Quote:
d
i
>v
>>
><?
> if($dataArray['dvd_image'] == "None")
> {
>?>
> <img id="img_<?=$recordCount?>" width="50"
height="70"
Quote:
Quote:
Quote:
>src="images/dvds/none_small.jpg"
>>
>
>
>>
>
>
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
Quote:
',img_<?=$recordCount?>.width
>+ 5,5)"
>onmouseout="popHide('infoLayer_<?=$recordCount?>' )">
><?
> }
> else
> {
>?>
> <img id="img_<?=$recordCount?>" width="50"
height="70"
Quote:
Quote:
Quote:
>src="images/dvds/<?=$dataArray['dvd_image']?>"
>>
>
>
>>
>
>
>
onmouseover="popShow(this,img_<?=$recordCount?>,'i nfoLayer_<?=$recordCount?>
Quote:
Quote:
Quote:
',img_<?=$recordCount?>.width
>+ 5,5)"
>onmouseout="popHide('infoLayer_<?=$recordCount?>' )">
><?
> }
> echo " <img
>>
>
>
>>
>
>
>
src='images/certs/".$certImage[$dataArray['certificate']].".gif'><BR>".$data
Quote:
Quote:
Quote:
Array['title'];
>?>
> </td>
> <td width="4">&nbsp;</td>
> <td><b>Released</b><br><?=$dataArray['year']?><br>
> <b>Duration</b><br><?=$dataArray['duration']?><br>
> <b>Rating</b><br><img alt="Rating:
><?=$dataArray['rating']/2?>"
>align="absmiddle"
>>
src="images/ratings/pips<?=$dataArray['rating']?>.gif"></td>
Quote:
Quote:
Quote:
> <td width="4">&nbsp;</td>
><?
> $recordCount++;
> }
>?>
> </tr>
><?
> }
>}
>----------------------------------
>>
>>
>"Ian Davies" <iandan.dav@virgin.netwrote in message
>news:j3wxg.1067$u4.703@newsfe3-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
Quote:
Quote:
Quote:
index
no
>of
the
record in a hidden field)
I wish the user to be able to edit the data in the
table,
so
I
>have
extracted the records into hiddenfield, textareas,
dropdown
list
>and
checkbox so that they can make changes.
I named these elements as arrays and wish to run an
sql
Quote:
Quote:
Quote:
to
take
>each
row
in
turn (and any changes made) and update the mysql
table.
Quote:
Quote:
Quote:
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
>
>
>
************************************************** ********************
Quote:
Quote:
Quote:
<form action="commentselect.php" method="post"
enctype="multipart/form-data"
name="UpdateComments">
<table width="100%" border="0" cellpadding="0"
cellspacing="2"
bgcolor="#FFFFFF">
<tr align="center" class="ListHeading">
<td width="20%" height="31">Category</td>
<td width="60%" height="31">Comment</td>
<td width="10%" height="31">Share</td>
</tr>
<tr class="BodyText">
<?php
while($row =& mysql_fetch_array($commentresults)) {
extract($row);
>
if ($i%2) {
$class = 'row1';
echo "<TR bgcolor=\"#CCCCCC\">\n";
>
} else {
$class = 'row2';
echo "<TR bgcolor=\"white\">\n";
}
$i += 1;
?>
<td width="20%" align="left"
class="bodytext"><select
name="category[]" style="WIDTH: 90%">
<option value="<?php echo $row['TypeID']; ?>"><?php
echo
Quote:
Quote:
Quote:
$row['typedesc'];
?></option>
<?php
$commenttype = mysql_query("SELECT * FROM commenttype
WHERE
>username
=
'$username'");
if (!$commenttype) {
exit('<p>Error performing query: ' . mysql_error() .
'</p>');
}
while($row1 =& mysql_fetch_array($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"
class="bodytext"><input
type="checkbox"
name="avail[]" value="checkbox" <?php
share($available);
Quote:
Quote:
Quote:
?>>
</td>
</tr>
<?php
}
?>
</table>
</form>
>
>
************************************************** **********
>
>
>>
>>
>
>
>>
>>
>
>
>
>
>>
>>
>
>
>>
>>
>
>
>>
>>
>
>
>
>

Closed Thread