Twister1004 Posted February 3, 2009 Share Posted February 3, 2009 Hey everyone! How are you all doing? Well, I'm back again with another issue I can't seem to logicaly figure out (Probably thinking too hard). Objective: I'm making a ticket system for a group I'm with, and what I want to do is kinda tricky. Well to me anyways. Issue: I can't seem to logically think out how to increase the ticket number available by the user's name. Meaning, a person can only have a max number of 5 tickets. So I am trying to figure out in a function how to check for a user's name and increase its value. File I've made. (Note: It's not the whole file. This is the part of the file that is only affecting this.) $_SESSION['pname'] = "Twister"; function ticketNumber(){ $countID = 0; $countTickets = mysql_query("SELECT COUNT(*) FROM `cype_tickets` WHERE `name` = 'Twister'"); while($countTicks = mysql_fetch_array($countTickets)){ ++$countID; return $countID; } } echo ticketNumber(); $gettickets = mysql_query("SELECT * FROM `cype_tickets` WHERE `name` = '{$_SESSION['pname']}' ORDER BY `ticketid` DESC LIMIT 6")or die(mysql_error()); $getnumber = mysql_num_rows($gettickets); $opentick = mysql_fetch_array($gettickets); while($tickets = mysql_fetch_array($gettickets)){ echo " <table border=\"1\"> <tr> <th> " . $tickets['ticketid'] . " </th> <td> <a href =\"?cype=main&page=ticket&a=$tickets[ticketid]&v=yes\"> " . $tickets['title'] . " </a> </td> <td> " . $tickets['date'] . " </td> <th> " . $tickets['status'] . " </th> </tr> "; } echo " </table>"; if($getnumber >= 5 && $opentick['status'] == "Open"){ echo "<b><center>Please wait until one of your tickets is solved before creating another one.</center></b>"; } else{ echo " <center> <input type=\"button\" value=\"Create Ticket\" onclick='parent.window.location = \"?cype=ucp&page=ticket&ticket=create\"' /> </center> "; } Thank you for your help. Quote Link to comment Share on other sites More sharing options...
Boo-urns Posted February 3, 2009 Share Posted February 3, 2009 So you're just looking to have 5 not be a static variable? i.e. they can have 7 tickets or 100 tickets etc...? What I do is I create a table for defaults and have a column for what you're going after. (ticketMax column = whatever maximum number) Unless, you aren't going to reuse it somewhere else you could always create a variable up top for ticket max and input it in your code <?php $ticketMax = 10; // or pull the maximum from the db if you do it that way. if($getnumber >= $ticketMax && $opentick['status'] == "Open"){ echo "<b><center>Please wait until one of your tickets is solved before creating another one.</center></b>"; } I hope that is what you were asking. Quote Link to comment Share on other sites More sharing options...
Twister1004 Posted February 3, 2009 Author Share Posted February 3, 2009 Never mind, I found another way around it =D. Thank you for your help! <3 Quote Link to comment 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.