473,325 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

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

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>

************************************************** **********
Jul 25 '06 #1
16 3446
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" <ia********@virgin.netwrote in message
news:j3***************@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 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>

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


Jul 26 '06 #2
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" <or***@psiss.comwrote in message
news:uF******************@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: 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>".$data
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" <ia********@virgin.netwrote in message
news:j3***************@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 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>

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


Jul 26 '06 #3
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" <ia********@virgin.netwrote in message
news:Bw******************@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 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" <or***@psiss.comwrote in message
news:uF******************@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: 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>".$data
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" <ia********@virgin.netwrote in message
news:j3***************@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 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>

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




Jul 26 '06 #4
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" <or***@psiss.comwrote in message
news:MQ***************@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 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" <ia********@virgin.netwrote in message
news:Bw******************@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 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" <or***@psiss.comwrote in message
news:uF******************@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: 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>".$data
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" <ia********@virgin.netwrote in message
news:j3***************@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 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>

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





Jul 27 '06 #5
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" <ia********@virgin.netwrote in message
news:Q9******************@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" <or***@psiss.comwrote in message
news:MQ***************@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 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" <ia********@virgin.netwrote in message
news:Bw******************@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 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" <or***@psiss.comwrote in message
news:uF******************@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: 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>".$data
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" <ia********@virgin.netwrote in message
news:j3***************@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 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>

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




Jul 27 '06 #6
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" <or***@psiss.comwrote in message
news:e7******************@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" <ia********@virgin.netwrote in message
news:Q9******************@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" <or***@psiss.comwrote in message
news:MQ***************@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
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" <ia********@virgin.netwrote in message
news:Bw******************@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 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" <or***@psiss.comwrote in message
news:uF******************@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: 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></di
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?>
',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>".$data
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" <ia********@virgin.netwrote in message
news:j3***************@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
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>

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







Jul 27 '06 #7
'....and a hidden field to contain...'
SHOULD READ
'....and I also have a hidden field that contains...'
ian
"Ian Davies" <ia********@virgin.netwrote in message
news:EJ*******************@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
arrays appropriately

Cheers
Ian
also I greatly appreciate your assistance
"PSI_Orion" <or***@psiss.comwrote in message
news:e7******************@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" <ia********@virgin.netwrote in message
news:Q9******************@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" <or***@psiss.comwrote in message
news:MQ***************@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
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" <ia********@virgin.netwrote in message
>news:Bw******************@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
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" <or***@psiss.comwrote in message
news:uF******************@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:
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></di
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?>
',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>".$data
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" <ia********@virgin.netwrote in message
>news:j3***************@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
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>
>
************************************************** **********
>
>
>>
>>
>
>
>>
>>
>
>


Jul 27 '06 #8
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" <ia********@virgin.netwrote in message
news:KL******************@newsfe4-win.ntli.net...
'....and a hidden field to contain...'
SHOULD READ
'....and I also have a hidden field that contains...'
ian
"Ian Davies" <ia********@virgin.netwrote in message
news:EJ*******************@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
arrays appropriately

Cheers
Ian
also I greatly appreciate your assistance
"PSI_Orion" <or***@psiss.comwrote in message
news:e7******************@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" <ia********@virgin.netwrote in message
news:Q9******************@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" <or***@psiss.comwrote in message
news:MQ***************@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
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" <ia********@virgin.netwrote in message
news:Bw******************@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
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" <or***@psiss.comwrote in message
news:uF******************@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:
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></di
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?>
',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>".$data
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" <ia********@virgin.netwrote in message
news:j3***************@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
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>

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






Jul 27 '06 #9
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" <or***@psiss.comwrote in message
news:aE*******************@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
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" <ia********@virgin.netwrote in message
news:KL******************@newsfe4-win.ntli.net...
'....and a hidden field to contain...'
SHOULD READ
'....and I also have a hidden field that contains...'
ian
"Ian Davies" <ia********@virgin.netwrote in message
news:EJ*******************@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
arrays appropriately

Cheers
Ian
also I greatly appreciate your assistance
"PSI_Orion" <or***@psiss.comwrote in message
news:e7******************@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" <ia********@virgin.netwrote in message
news:Q9******************@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" <or***@psiss.comwrote in message
news:MQ***************@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
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" <ia********@virgin.netwrote in message
>news:Bw******************@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
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" <or***@psiss.comwrote in message
news:uF******************@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:
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></d
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?>
',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>".$data
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" <ia********@virgin.netwrote in message
>news:j3***************@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
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>
>
************************************************** **********
>
>
>>
>>
>
>
>>
>>
>
>





Jul 27 '06 #10
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" <ia********@virgin.netwrote in message
news:35*************@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
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" <or***@psiss.comwrote in message
news:aE*******************@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
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" <ia********@virgin.netwrote in message
news:KL******************@newsfe4-win.ntli.net...
'....and a hidden field to contain...'
SHOULD READ
'....and I also have a hidden field that contains...'
ian
"Ian Davies" <ia********@virgin.netwrote in message
news:EJ*******************@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
arrays appropriately

Cheers
Ian
also I greatly appreciate your assistance
"PSI_Orion" <or***@psiss.comwrote in message
news:e7******************@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" <ia********@virgin.netwrote in message
news:Q9******************@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" <or***@psiss.comwrote in message
news:MQ***************@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
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" <ia********@virgin.netwrote in message
news:Bw******************@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
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" <or***@psiss.comwrote in message
news:uF******************@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:
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></d
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?>
',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>".$data
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" <ia********@virgin.netwrote in message
news:j3***************@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
>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>

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








Jul 27 '06 #11
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" <ia********@virgin.netwrote in message
news:35*************@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
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" <or***@psiss.comwrote in message
news:aE*******************@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
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" <ia********@virgin.netwrote in message
news:KL******************@newsfe4-win.ntli.net...
'....and a hidden field to contain...'
SHOULD READ
'....and I also have a hidden field that contains...'
ian
"Ian Davies" <ia********@virgin.netwrote in message
news:EJ*******************@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
arrays appropriately

Cheers
Ian
also I greatly appreciate your assistance
"PSI_Orion" <or***@psiss.comwrote in message
news:e7******************@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" <ia********@virgin.netwrote in message
news:Q9******************@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" <or***@psiss.comwrote in message
news:MQ***************@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
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" <ia********@virgin.netwrote in message
news:Bw******************@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
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" <or***@psiss.comwrote in message
news:uF******************@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:
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></d
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?>
',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>".$data
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" <ia********@virgin.netwrote in message
news:j3***************@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
>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>

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








Jul 27 '06 #12
yes
I think that is what im looking for but your code isnt visible
Did you use arrays?
"PSI_Orion" <or***@psiss.comwrote in message
news:ZN*************@newsfe2-gui.ntli.net...
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" <ia********@virgin.netwrote in message
news:35*************@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
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" <or***@psiss.comwrote in message
news:aE*******************@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
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" <ia********@virgin.netwrote in message
news:KL******************@newsfe4-win.ntli.net...
'....and a hidden field to contain...'
SHOULD READ
'....and I also have a hidden field that contains...'
ian
"Ian Davies" <ia********@virgin.netwrote in message
news:EJ*******************@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
arrays appropriately

Cheers
Ian
also I greatly appreciate your assistance
"PSI_Orion" <or***@psiss.comwrote in message
news:e7******************@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" <ia********@virgin.netwrote in message
news:Q9******************@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" <or***@psiss.comwrote in message
news:MQ***************@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
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" <ia********@virgin.netwrote in message
>news:Bw******************@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
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" <or***@psiss.comwrote in message
news:uF******************@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:
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></
d
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?>
',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>".$data
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" <ia********@virgin.netwrote in message
>news:j3***************@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
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>
>
>
************************************************** **********
>
>
>>
>>
>
>
>>
>>
>
>







Jul 27 '06 #13
Cheers.
that would be great
Ian

"PSI_Orion" <or***@psiss.comwrote in message
news:vn*****************@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" <ia********@virgin.netwrote in message
news:35*************@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
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" <or***@psiss.comwrote in message
news:aE*******************@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
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" <ia********@virgin.netwrote in message
news:KL******************@newsfe4-win.ntli.net...
'....and a hidden field to contain...'
SHOULD READ
'....and I also have a hidden field that contains...'
ian
"Ian Davies" <ia********@virgin.netwrote in message
news:EJ*******************@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
arrays appropriately

Cheers
Ian
also I greatly appreciate your assistance
"PSI_Orion" <or***@psiss.comwrote in message
news:e7******************@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" <ia********@virgin.netwrote in message
news:Q9******************@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" <or***@psiss.comwrote in message
news:MQ***************@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
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" <ia********@virgin.netwrote in message
>news:Bw******************@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
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" <or***@psiss.comwrote in message
news:uF******************@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:
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></
d
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?>
',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>".$data
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" <ia********@virgin.netwrote in message
>news:j3***************@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
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>
>
>
************************************************** **********
>
>
>>
>>
>
>
>>
>>
>
>







Jul 28 '06 #14
File sent.

"Ian Davies" <ia********@virgin.netwrote in message
news:Q0******************@newsfe5-win.ntli.net...
Cheers.
that would be great
Ian

"PSI_Orion" <or***@psiss.comwrote in message
news:vn*****************@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" <ia********@virgin.netwrote in message
news:35*************@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
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" <or***@psiss.comwrote in message
news:aE*******************@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
>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" <ia********@virgin.netwrote in message
news:KL******************@newsfe4-win.ntli.net...
'....and a hidden field to contain...'
SHOULD READ
'....and I also have a hidden field that contains...'
ian
"Ian Davies" <ia********@virgin.netwrote in message
news:EJ*******************@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
>arrays appropriately

Cheers
Ian
also I greatly appreciate your assistance
"PSI_Orion" <or***@psiss.comwrote in message
news:e7******************@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" <ia********@virgin.netwrote in message
news:Q9******************@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" <or***@psiss.comwrote in message
news:MQ***************@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
>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" <ia********@virgin.netwrote in message
news:Bw******************@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
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" <or***@psiss.comwrote in message
news:uF******************@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:
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></
d
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?>
',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>".$data
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" <ia********@virgin.netwrote in message
news:j3***************@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
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>

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









Jul 28 '06 #15
Well, it would have been if the email addy was correct...

"PSI_Orion" <or***@psiss.comwrote in message
news:me****************@newsfe3-win.ntli.net...
File sent.

"Ian Davies" <ia********@virgin.netwrote in message
news:Q0******************@newsfe5-win.ntli.net...
>Cheers.
that would be great
Ian

"PSI_Orion" <or***@psiss.comwrote in message
news:vn*****************@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" <ia********@virgin.netwrote in message
news:35*************@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
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" <or***@psiss.comwrote in message
news:aE*******************@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
>>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" <ia********@virgin.netwrote in message
news:KL******************@newsfe4-win.ntli.net...
'....and a hidden field to contain...'
SHOULD READ
'....and I also have a hidden field that contains...'
ian
"Ian Davies" <ia********@virgin.netwrote in message
news:EJ*******************@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
>>arrays appropriately

Cheers
Ian
also I greatly appreciate your assistance
"PSI_Orion" <or***@psiss.comwrote in message
news:e7******************@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" <ia********@virgin.netwrote in message
news:Q9******************@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" <or***@psiss.comwrote in message
news:MQ***************@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
>>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" <ia********@virgin.netwrote in message
news:Bw******************@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
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" <or***@psiss.comwrote in message
news:uF******************@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:
>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></
d
>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?>
>',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?>
>',img_<?=$recordCount?>.width
+ 5,5)"
onmouseout="popHide('infoLayer_<?=$recordCount?> ')">
<?
}
echo " <img

src='images/certs/".$certImage[$dataArray['certificate']].".gif'><BR>".$data
>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" <ia********@virgin.netwrote in message
news:j3***************@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
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>

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









Jul 28 '06 #16
sorry
try
ianDOTdandavATvirginDOTnet

"PSI_Orion" <or***@psiss.comwrote in message
news:Or*******************@newsfe5-win.ntli.net...
Well, it would have been if the email addy was correct...

"PSI_Orion" <or***@psiss.comwrote in message
news:me****************@newsfe3-win.ntli.net...
File sent.

"Ian Davies" <ia********@virgin.netwrote in message
news:Q0******************@newsfe5-win.ntli.net...
Cheers.
that would be great
Ian

"PSI_Orion" <or***@psiss.comwrote in message
news:vn*****************@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" <ia********@virgin.netwrote in message
news:35*************@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
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" <or***@psiss.comwrote in message
news:aE*******************@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
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" <ia********@virgin.netwrote in message
news:KL******************@newsfe4-win.ntli.net...
'....and a hidden field to contain...'
SHOULD READ
'....and I also have a hidden field that contains...'
ian
"Ian Davies" <ia********@virgin.netwrote in message
news:EJ*******************@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
arrays appropriately

Cheers
Ian
also I greatly appreciate your assistance
"PSI_Orion" <or***@psiss.comwrote in message
news:e7******************@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" <ia********@virgin.netwrote in message
news:Q9******************@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" <or***@psiss.comwrote in message
news:MQ***************@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
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" <ia********@virgin.netwrote in message
news:Bw******************@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
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" <or***@psiss.comwrote in message
news:uF******************@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:
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>
</
d
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?>
',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>".$data
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" <ia********@virgin.netwrote in message
news:j3***************@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
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>
************************************************** **********









Jul 29 '06 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jason | last post by:
Currently I have a number of html forms which loop through records in a database table. In order to be able to update the right record when the form is submitted, I've tacked number on to the...
1
by: mursyidatun ismail | last post by:
Dear all, database use: Ms Access. platform: .Net i'm trying to update a record/records in a table called t_doctors by clicking da edit link provided in the database. when i ran through da...
11
by: pmarisole | last post by:
I am trying to use the vbscript "split" function on a multi-select field. I am trying to do a mass update of several records at a time. I am getting an error and I'm not sure what to do. Here is...
10
by: Roger Withnell | last post by:
I'm using ASP, VBScript and SQL Server. I'm also using UTF-8 character set and so my codepage is 65001 and SQL Server datatype nvarchar. I can insert unicode characters correctly into the...
5
by: cover | last post by:
I have an input form that passes data when submitted to a second form to let the user know what they have just entered into the db. My question comes with using 'update'. I'd like to query the...
4
by: mantrid | last post by:
Im using arrays generated from my records displayed in a table on my site to update the corresponding records in a mysql database ie on the web page col1 col2 col3 1 2 2 1 ...
10
by: MLH | last post by:
Suppose, in a multi-user environment, you have append query SQL in a VBA procedure that looks like INSERT INTO MyTable... and the next line reads MyVar=DMax("","MyTable... You can never be...
1
by: javediq143 | last post by:
Hi All, This is my first post in this forum. I'm developing a CMS for my latest website. This CMS is also in PhP & MySQL. I'm done with the ADD section where the Admin can INSERT new records in...
3
by: planethax | last post by:
I have multiple arrays that I need to insert/update database and I am not sure how to start, I think I need to use the "foreach" statement and also not sure whether or not to serialize and...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.