Page 1 of 1
table update?
Posted: Tue Jun 19, 2012 1:07 am
by jayson.ph
hi all,
i have table below, that need for update but i have no idea on how, should it do. that after i click a data inside a table it should be editable. please help

Re: table update?
Posted: Tue Jun 19, 2012 3:22 am
by Grizzzzzzzzzz
Re: table update?
Posted: Tue Jun 19, 2012 3:44 am
by jayson.ph
Thank you .Grizzzzzzzzzz .
and also have here, but it not work and i know it is near from what im looking. please help..
update.php
Code: Select all
$id = $_GET['rid'];
$pingsql = "SELECT * FROM tbl_brn_requst WHERE rid = '$id'";
$pingresult = mysql_query($pingsql);
$rows = mysql_fetch_array($pingresult);
?>
<form name = "frm_return_request" method = "GET" action = "#">
Branch<input type="text" name="txtbranch" value = "<? echo $rows['tbl_brnch_name'];?>">
Categoty<input type="text" name="txtbranch" value = "<? echo $rows['cat_name'];?>">
Item Name<input type="text" name="txtbranch" value = "<? echo $rows['product_name'];?>">
Item Code<input type="text" name="txtbranch" value = "<? echo $rows['product_model'];?>">
Receive/onhand<input type="text" name="txtbranch" value = "<? echo $rows['rec_on'];?>">
Return<input type="text" name="txtbranch" value = "<? echo $rows['return_on'];?>">
Suld<input type="text" name="txtbranch" value = "<? echo $rows['balancs'];?>">
Balance<input type="text" name="txtbranch" value = "<? echo $rows['sold'];?>">
Quantity Request<input type="text" name="txtbranch" value = "<? echo $rows['re_qty'];?>">
Date<input type="text" name="txtbranch" value = "<? echo $rows['dt_nwo'];?>">
Userlog<input type="text" name="txtbranch" value = "<? echo $rows['commnt'];?>">
<input name = "id" type = "hidden" id = "id" value = "<? echo $rows['rid'];?>">
table.php
Code: Select all
$pingsql = "SELECT tbl_user.uid,tbl_user.tbl_brnch_name,tbl_brn_requst.cat_name,tbl_brn_requst.product_name,tbl_brn_requst.product_model,tbl_brn_requst.rec_on,tbl_brn_requst.return_on,tbl_brn_requst.balancs,tbl_brn_requst.sold,tbl_brn_requst.re_qty,tbl_brn_requst.dt_nwo,tbl_brn_requst.commnt FROM tbl_user INNER JOIN tbl_brn_requst ON tbl_user.uid = tbl_brn_requst.uid";
$pingresult = mysql_query($pingsql) or die ("Query Failed($pingsql) ".mysql_error());
echo '<table><th>BRANCH</th> <th>CATEGORY</th> <th>ITEM NAME</th> <th>ITEM MODEL</th> <th>RECEIVE</th> <th>RETURN</th> <th>SOLD</th> <th>BALANCE</th> <th>Q-REQ</th> <th>DATE-REQ</th><th>LOG</th><th>UPDATE</th>';
if(mysql_num_rows($pingresult))
{
while($rows = mysql_fetch_array($pingresult))
{
echo '<tr>';
echo '<td>'. $rows['tbl_brnch_name'] .'</td>';
echo '<td>' . $rows['cat_name'] . '</td>';
echo '<td>' . $rows['product_name'] . '</td>';
echo '<td>' . $rows['product_model'] . '</td>';
echo '<td style = "text-align:center;">' . $rows['rec_on'] . '</td>';
echo '<td style = "text-align:center;">' . $rows['return_on'] . '</td>';
echo '<td style = "text-align:center;">' . $rows['balancs'] . '</td>';
echo '<td style = "text-align:center;">' . $rows['sold'] . '</td>';
echo '<td style = "text-align:center;">' . $rows['re_qty'] . '</td>';
echo '<td>' . $rows['dt_nwo'] . '</td>';
echo '<td>' . $rows['commnt'] . '</td>';
echo '<td style = "text-align:center;"><a href = "../public-functions/update_function/return_request.php?rid=.$rows[rid].">UPDATE</a></td>';
echo '</tr>';
}
echo '</table>';
}
Output-->

Re: table update?
Posted: Tue Jun 19, 2012 8:42 am
by mikosiko
in your update.php did you try using long tags instead of the short ones? .... ie: <?php echo $rows['tbl_brnch_name']; ?> instead of what you have today
Re: table update?
Posted: Tue Jun 19, 2012 8:21 pm
by jayson.ph
I try that, but same error.
[text]in your update.php did you try using long tags instead of the short ones? .... ie: <?php echo $rows['tbl_brnch_name']; ?> instead of what you have today[/text]
Re: table update?
Posted: Tue Jun 19, 2012 10:39 pm
by jayson.ph
i change the code from my update.php but my problem now is only 1st row he read when i click update from the table see image below.
output from update.php
code for udate:
Code: Select all
$id = $_GET['id'];
$pingsql = "SELECT tbl_user.uid,tbl_user.tbl_brnch_name,tbl_brn_requst.id,tbl_brn_requst.cat_name,tbl_brn_requst.product_name,tbl_brn_requst.product_model,tbl_brn_requst.rec_on,tbl_brn_requst.return_on,tbl_brn_requst.balancs,tbl_brn_requst.sold,tbl_brn_requst.re_qty,tbl_brn_requst.dt_nwo,tbl_brn_requst.commnt FROM tbl_user INNER JOIN tbl_brn_requst ON tbl_user.uid = tbl_brn_requst.uid";
$pingresult = mysql_query($pingsql) or die ("Server query error. $ $pingsql. " .mysql_error());
if(mysql_num_rows($pingresult) > 0)
{
$rows = mysql_fetch_object($pingresult);
?>
<form name = "frm_update_req" method = "POST">
<input name = "id" type = "hidden" value = "<?php echo $id; ?>">
<input name = "tbl_brnch_name" type = "text" value = "<?php echo $rows->tbl_brnch_name; ?>">
<input name = "cat_name" type = "text" value = "<?php echo $rows->cat_name; ?>">
<input name = "product_name" type = "text" value = "<?php echo $rows->product_name; ?>">
<input name = "product_model" type = "text" value = "<?php echo $rows->product_model; ?>">
<input name = "rec_on" type = "text" value = "<?php echo $rows->rec_on; ?>">
<input name = "return_on" type = "text" value = "<?php echo $rows->return_on; ?>">
<input name = "sold" type = "text" value = "<?php echo $rows->sold; ?>">
<input name = "balancs" type = "text" value = "<?php echo $rows->balancs; ?>">
<input name = "re_qty" type = "text" value = "<?php echo $rows->re_qty; ?>">
<input name = "dt_nwo" type = "text" value = "<?php echo $rows->dt_nwo; ?>">
<input name = "commnt" type = "text" value = "<?php echo $rows->commnt; ?>">
<input name = "subreq" type = "submit" value = "Update">
<?php
}
?>
and from the url look like this: /update_function/update.php?id=<?php echo $rows->uid; ?> and i think it is from my database, please help me and advice..
Re: table update?[SOLVE]
Posted: Wed Jun 20, 2012 12:36 am
by jayson.ph
Finally i get it. here are the source:
for a the table:
Code: Select all
$pingsql = "SELECT tbl_user.uid,tbl_user.tbl_brnch_name,tbl_brn_requst.id,tbl_brn_requst.cat_name,tbl_brn_requst.product_name,tbl_brn_requst.product_model,tbl_brn_requst.rec_on,tbl_brn_requst.return_on,tbl_brn_requst.balancs,tbl_brn_requst.sold,tbl_brn_requst.re_qty,tbl_brn_requst.dt_nwo,tbl_brn_requst.commnt FROM tbl_user INNER JOIN tbl_brn_requst ON tbl_user.uid = tbl_brn_requst.uid";
$pingresult = mysql_query($pingsql) or die ("Query Failed($pingsql) ".mysql_error());
?>
<table><th>BRANCH</th> <th>CATEGORY</th> <th>ITEM NAME</th> <th>ITEM MODEL</th> <th>RECEIVE</th> <th>RETURN</th> <th>SOLD</th> <th>BALANCE</th> <th>Q-REQ</th> <th>DATE-REQ</th><th>LOG</th><th>UPDATE</th>
<?php
if(mysql_num_rows($pingresult))
{
while($rows = mysql_fetch_array($pingresult))
{
?>
<tr>
<td><?php echo $rows['tbl_brnch_name']; ?></td>
<td><?php echo $rows['cat_name']; ?></td>
<td><?php echo $rows['product_name']; ?></td>
<td><?php echo $rows['product_model']; ?></td>
<td style = "text-align:center;"><?php echo $rows['rec_on']; ?></td>
<td style = "text-align:center;"><?php echo $rows['return_on']; ?></td>
<td style = "text-align:center;"><?php echo $rows['sold']; ?></td>
<td style = "text-align:center;"><?php echo $rows['balancs']; ?></td>
<td style = "text-align:center;"><?php echo $rows['re_qty']; ?></td>
<td><?php echo $rows['dt_nwo']; ?></td>
<td><?php echo $rows['commnt']; ?></td>
<td style = "text-align:center;"><a href = "../public-functions/update_function/return_request.php?id=<?php echo $rows['id']; ?>">UPDATE</a></td>
</tr>
<?php
}
?>
</table>
<?php
}
?>
update.php
Code: Select all
$id = $_GET['id'];
$pingsql = "SELECT * FROM tbl_brn_requst WHERE id = '$id'";
$pingresult = mysql_query($pingsql) or die ("Server query error. $ $pingsql. " .mysql_error());
if(mysql_num_rows($pingresult) > 0)
{
while($rows = mysql_fetch_array($pingresult))
{
?>
<form name = "frm_update_req" method = "POST">
<input name = "id" type = "hidden" value = "<?php echo $rows['id']; ?>">
<input name = "cat_name" type = "text" value = "<?php echo $rows['cat_name']; ?>">
<input name = "product_name" type = "text" value = "<?php echo $rows['product_name']; ?>">
<input name = "product_model" type = "text" value = "<?php echo $rows['product_model']; ?>">
<input name = "rec_on" type = "text" value = "<?php echo $rows['rec_on']; ?>">
<input name = "return_on" type = "text" value = "<?php echo $rows['return_on']; ?>">
<input name = "sold" type = "text" value = "<?php echo $rows['sold']; ?>">
<input name = "balancs" type = "text" value = "<?php echo $rows['balancs']; ?>">
<input name = "re_qty" type = "text" value = "<?php echo $rows['re_qty']; ?>">
<input name = "dt_nwo" type = "text" value = "<?php echo $rows['dt_nwo']; ?>">
<input name = "commnt" type = "text" value = "<?php echo $rows['commnt'];?>">
<input name = "subreq" type = "submit" value = "Update">
</form>
<?php
}
}
?>