labyrinth00 Posted February 10, 2012 Share Posted February 10, 2012 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; } Quote Link to comment https://forums.phpfreaks.com/topic/256791-need-some-help-please/ Share on other sites More sharing options...
delickate Posted February 10, 2012 Share Posted February 10, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/256791-need-some-help-please/#findComment-1316448 Share on other sites More sharing options...
labyrinth00 Posted February 10, 2012 Author Share Posted February 10, 2012 sorry to be a novice but how do i show the database structure? and i am not sure where to insert the edited code. thanks for th reply though Quote Link to comment https://forums.phpfreaks.com/topic/256791-need-some-help-please/#findComment-1316565 Share on other sites More sharing options...
jcbones Posted February 10, 2012 Share Posted February 10, 2012 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)) { Quote Link to comment https://forums.phpfreaks.com/topic/256791-need-some-help-please/#findComment-1316828 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.