Jump to content

need some help please


labyrinth00

Recommended Posts

Greetings to all,  i have no experience in php and i am having a hard time finding help so here i am.  i have a problem when i click a button "see all tickets" only tickets that were created by the last user shows up but not all from the database.  i would really like this fixed so i can really see all tickets in the database. 

 

thanks

 

function SeeAllTheTickets() {
  if ($_REQUEST[pcc] == '') { $pcc = '0'; } else { $pcc = $_REQUEST[pcc]; }
?>
<div align="center"><p><b>Showing All Tickets on the Database</b></p>
<table width="500" cellpadding="2" cellspacing="0">
<tr>
  <td align="center" class="header">Owner Info</td>
  <td align="center" class="header">Ticket Number</td>
  <td align="center" class="header">Bought On</td>
</tr>
<?php
  $mysql = mysql_query("SELECT owner_mnum FROM ".MYSQL_PREFIX."_tickets WHERE active='1'");
  while ($t = @mysql_fetch_array($mysql)) { $ab = $t[owner_mnum]; $mnums[$ab] = 'a'; }
  foreach ($mnums as $mnum => $trash) {
    $mysql = mysql_query("SELECT * FROM ".MYSQL_PREFIX."_members WHERE mnum='$mnum'");
while ($a = @mysql_fetch_array($mysql)) { $num = $a[mnum]; $real_mnums[$num] = $a[first]." ".$a[last]." (".$a[email].")"; }
}
  $mysql = mysql_query("SELECT * FROM `".MYSQL_PREFIX."_tickets` WHERE `owner_mnum`='$mnum' ORDER BY `time_stamp` ASC");
  $count = @mysql_num_rows($mysql); if ($count > MAX_RESULTS) { $limit = " LIMIT ".$pcc.",".MAX_RESULTS; } else { $limit = ''; }
  $mysql = mysql_query("SELECT * FROM `".MYSQL_PREFIX."_tickets` WHERE `owner_mnum`='$mnum' ORDER BY `time_stamp` ASC$limit");
  while ($t = @mysql_fetch_array($mysql)) {
?>
<tr>
  <td align="center"><?php $nm = $t[owner_mnum]; echo $real_mnums[$nm]; ?></td>
  <td align="center"><?php echo $t[tnum] ?></td>
  <td align="center"><?php echo $t[thedate].' at '.$t[thetime] ?></td>
</tr>
<tr><td align="center" colspan="3"><?php if ($t[paypal_txn]) { ?>PayPal Transaction #<b><?php echo $t[paypal_txn] ?></b><br /><br /><?php } ?><a href="tickets.php?action=+Delete+Ticket+&tnum=<?php echo $t[tnum] ?>">Delete Ticket</a></td></tr>
<tr><td colspan="3" height="2" class="divider"></td></tr>
<?php
$shown++; }
?>
</table>
<?php 
  if ($shown < 1) { ?><p align="center" class="warning">There are no Tickets on your database.</b></p><?php echo "\n"; }
  elseif ($count > MAX_RESULTS) { ?><p><b>Showing Tickets <?php $uno = $pcc + 1; echo $uno; ?> - <?php $new_pcc = $pcc + MAX_RESULTS; if ($new_pcc < $count) { echo $new_pcc; } else { echo $count; } ?> of <?php echo $count ?> Total</b></p><?php echo "\n"; }
  $shown = 0; if ($_REQUEST[pcc] > 0) { ?><p><a href="tickets.php?action=+See+All+The+Tickets+&pcc=<?php $num = $pcc - MAX_RESULTS; echo $num; ?>">Previous Page</a><? $shown++; }
  if ($new_pcc < $count && $count > MAX_RESULTS) { if ($shown) { ?> - <?php } else { ?><p><?php } ?><a href="tickets.php?action=+See+All+The+Tickets+&pcc=<?php echo $new_pcc; ?>">Next Page</a></p><? }
?>
</div>
<?php
  ShowPageInfo('Template Footer'); exit; }

Link to comment
Share on other sites

hi,

show your database structure. If you're trying to fetch data from one then its very simple otherwise you've to join tables in query and do it as follow:

 

$mysql = mysql_query("SELECT owner_mnum FROM ".MYSQL_PREFIX."_tickets WHERE active='1'");
  while ($t = mysql_fetch_array($mysql)) 
{ 
?>
<tr>
  <td align="center"><?php $nm = $t[owner_mnum]; ?></td>
  <td align="center"><?php echo $t[tnum] ?></td>
  <td align="center"><?php echo $t[thedate].' at '.$t[thetime] ?></td>
</tr>
<tr><td align="center" colspan="3"><?php if ($t[paypal_txn]) { ?>PayPal Transaction #<b><?php echo $t[paypal_txn] ?></b><br /><br /><?php } ?><a href="tickets.php?action=+Delete+Ticket+&tnum=<?php echo $t[tnum] ?>">Delete Ticket</a></td></tr>
<tr><td colspan="3" height="2" class="divider"></td></tr>
<?php

}
?>
</table>

 

Never uses @ sign. It hides the errors...

Hope it'll help you

Link to comment
Share on other sites

Why all the database request?

 

I'm pretty sure you can get rid of all but one of them, if you think about it.

 

$sql = "SELECT t.* FROM ".MYSQL_PREFIX."_tickets AS t JOIN " . MYSQL_PREFIX . "_members AS m ON t.owner_mnum = m.mnum WHERE active='1' LIMIT $pcc," . MAX_RESULTS;
$mysql = mysql_query($sql) or trigger_error($sql . ' has encountered an error:<br />' . mysql_error());
  while ($t = mysql_fetch_array($mysql)) {

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.