Hello All,
I'm trying to modify some code for an auction site but my lack of PHP knowledge is preventing me from doing so.
I bought an "Essential Guide To CSS, AJAX,& PHP" book and have been doing the PHP exercises at the W3 site, but it seems that it'll be some time before I have a real grasp of what it is I'm trying to do. I'm hoping that one of you will be able to help me or steer me in the right direction.
There are three pages that I need to help with - a php page, the corresponding tpl, and a redirect php page to catch and display the info passed to it. (I know what your thinking but I am trying to learn as fast as I can, it's just all very confusing).
The first page generates an items list which the tpl displays with a checkbox next to each item. The user can then tick a checkbox(s) and click a button to delete the item(s) from the list. Instead of deleting the item(s) from the list I would rather it just pass the info to another page and list those checked item(s).
I don't want to be a jerk and post 800 lines of code, so here are the snippets that I'm having trouble with - and thank you for looking, I appreciate it.
The first php page snippet looks like this:
// DELETE OR CLOSE OPEN AUCTIONS
if (isset($_POST['action']) && $_POST['action'] == 'delopenauctions')
{
if (is_array($_POST['O_delete']) && count($_POST['O_delete']) > 0)
{
$removed = 0;
foreach ($_POST['O_delete'] as $k => $v)
{
$v = intval($v);
// Pictures Gallery
if (file_exists($upload_path . $v))
{
if ($dir = @opendir($upload_path . $v))
{
while ($file = readdir($dir)) {
if ($file != '.' && $file != '..')
{
@unlink($upload_path . $v . '/' . $file);
}
}
closedir($dir);
@rmdir($upload_path . $v);
}
}
// Delete Invited Users List and Black Lists associated with this auction
$query = "DELETE FROM " . $DBPrefix . "auccounter WHERE auction_id = " . $v;
$system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
// Auction
$query = "DELETE FROM " . $DBPrefix . "auctions WHERE id = " . $v;
$system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
$removed++;
}
$query = "UPDATE " . $DBPrefix . "counters SET auctions = (auctions - " . $removed . ")";
$system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
}
if (is_array($_POST['closenow']))
{
foreach ($_POST['closenow'] as $k => $v)
{
The corresponding tpl snippet looks as so:
<script type="text/javascript">
$(document).ready(function() {
$("#closeall").click(function() {
$("input[@class=closenow]").each(function() {
if (this.checked) {
this.checked = false;
} else {
this.checked = true;
}
});
return false;
});
$("#deleteall").click(function() {
$("input[@class=O_delete]").each(function() {
if (this.checked) {
this.checked = false;
} else {
this.checked = true;
}
});
return false;
});
$("#processdel").submit(function() {
if (confirm('{L_30_0087}')){
return true;
} else {
return false;
}
});
});
</script>
<form name="auctions" method="post" action="" id="processdel">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td colspan="9" align="right">
<dl class="tabs">
<dd><a href="yourauctions_p.php">{L_25_0115}</a></dd>
<dd><a href="yourauctions_c.php">{L_204}</a></dd>
<dd><a href="yourauctions_s.php">{L_2__0056}</a></dd>
<dd><a href="yourauctions_sold.php">{L_25_0119}</a></dd>
</dl>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="1" cellpadding="4" align="CENTER">
<tr bgcolor="{TBLHEADERCOLOUR}">
<td class="titTable1" width="32%">
<a href="yourauctions.php?oa_ord=title&oa_type={ORDERNEXT}">{L_624}</a>
<!-- IF ORDERCOL eq 'title' -->
<a href="yourauctions.php?oa_ord=title&oa_type={ORDERNEXT}">{ORDERTYPEIMG}</a>
<!-- ENDIF -->
</td>
<td class="titTable1" width="11%">
<a href="yourauctions.php?oa_ord=starts&oa_type={ORDERNEXT}">{L_625}</a>
<!-- IF ORDERCOL eq 'starts' -->
<a href="yourauctions.php?oa_ord=starts&oa_type={ORDERNEXT}">{ORDERTYPEIMG}</a>
<!-- ENDIF -->
</td>
<td class="titTable1" width="11%">
<a href="yourauctions.php?oa_ord=ends&oa_type={ORDERNEXT}">{L_626}</a>
<!-- IF ORDERCOL eq 'ends' -->
<a href="yourauctions.php?oa_ord=ends&oa_type={ORDERNEXT}">{ORDERTYPEIMG}</a>
<!-- ENDIF -->
</td>
<td class="titTable1" align="center" nowrap="nowrap">
{L__0153}
</td>
<td class="titTable1" width="7%" align="center">
<a href="yourauctions.php?oa_ord=num_bids&oa_type={ORDERNEXT}">{L_627}</a>
<!-- IF ORDERCOL eq 'num_bids' -->
<a href="yourauctions.php?oa_ord=num_bids&oa_type={ORDERNEXT}">{ORDERTYPEIMG}</a>
<!-- ENDIF -->
</td>
<td class="titTable1" width="10%" align="center">
<a href="yourauctions.php?oa_ord=current_bid&oa_type={ORDERNEXT}">{L_628}</a>
<!-- IF ORDERCOL eq 'current_bid' -->
<a href="yourauctions.php?oa_ord=current_bid&oa_type={ORDERNEXT}">{ORDERTYPEIMG}</a>
<!-- ENDIF -->
</td>
<td class="titTable1" width="6%" align="center">
{L_298}
</td>
<td class="titTable1" width="8%" align="center">
{L_008}
</td>
<td class="titTable1" width="6%" align="center" bgcolor="#FFFF00">
{L_2__0048}
</td>
</tr>
<!-- IF B_AREITEMS -->
<!-- BEGIN items -->
<tr bgcolor="#EEEEEE">
<td width="32%">
<a href="item.php?id={items.ID}">{items.TITLE}</a>
<br>
[{L_30_0081}{items.COUNTER}{L__0151}]</td>
<td width="11%">
{items.STARTS}
</td>
<td width="11%">
{items.ENDS}
</td>
<td width="9%" align="center">
<!-- IF items.RELISTED eq 0 -->
--
<!-- ELSE -->
{items.RELISTED}
<!-- ENDIF -->
</td>
<td width="7%" align="center">
{items.BIDS}
</td>
<td width="10%" align="center">
<!-- IF items.B_HASNOBIDS -->
-
<!-- ELSE -->
{items.BID}<br>[{L_159} <a href="profile.php?user_id={items.BIDDERID}">{items.BIDDER}</a>]
<!-- ENDIF -->
</td>
<td width="6%" align="center">
<!-- IF items.B_HASNOBIDS -->
<a href="edit_active_auction.php?id={items.ID}"><img src="images/edititem.gif" width="13" height="17" alt="{L_512}" border="0"></a>
<!-- ENDIF -->
</td>
<td width="8%" align="center">
<!-- IF items.B_HASNOBIDS -->
<input type="checkbox" name="O_delete[]" value="{items.ID}" class="O_delete">
<!-- ENDIF -->
</td>
<td width="6%" align="center" bgcolor="#FFFFaa">
<input type="checkbox" name="closenow[]" value="{items.ID}" class="closenow">
</td>
</tr>
<!-- END items -->
<!-- ENDIF -->
<tr bgcolor="{BGCOLOUR}">
<td colspan="7"> </td>
<td align="center"><a href="#" id="deleteall">{L_30_0102}</a></td>
<td align="center"><a href="#" id="closeall">{L_30_0102}</a></td>
</tr>
<tr>
<td colspan="9" align="center">
<input type="hidden" name="action" value="delopenauctions">
<input type="submit" name="Submit" value="{L_631}" class="button">
</td>
</tr>
</table>
</form>
The third page only needs to catch the info and post it. I made this:
<?php
$myitems = $_POST['closenow[]'];
echo "myitems: ".$myitems."<br>";
?>
The tpl displays two sets of checkboxes - "delete" & "close now". I only need one set of checkboxes.
Editing only the tpl file I was able to rid the page of everything but the items listed and the closenow checkbox column. Further finagling allowed me to send the {items.ID} & {items.TITLE} to the catch page but would only "catch" the info from the lowest ticked checkbox instead of all checkboxes ticked. I'm assuming this is because I was editing the tpl when I should have been editing the loop in the underlying php page - IDK.
All the code above is unaltered from the source material so as not to confuse you with my sloppy attempts to get this to work. If I'm not clarify everything correctly please, let me know. Any and all help would be appreciated, thank you for your time.