Jump to content

flashbangpro

Members
  • Posts

    45
  • Joined

  • Last visited

    Never

Everything posted by flashbangpro

  1. I am very new to php and trying to teach myself as I go with the help of fellow coders like yourself, so I apologize for the lack in understanding some times, and I do appreciate everything everyone has done to help.
  2. Here is the code to the page that is suppose to give the id when you select a record to update. <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Service Order Database</title> <link href="nav.css" rel="stylesheet" type="text/css"><!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <?php require_once("dbcon.php"); ?> <?php require_once("functions.php"); ?> <?php $query="SELECT * FROM service_info ORDER BY id"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; // process form when posted if(isset($_POST['value'])) { if($_POST['value'] == 'Engine') { // query to get all Engine records $query = "SELECT * FROM servifce_info WHERE issues_reported='Engine'"; }elseif($_POST['value'] == 'Transmission') { // query to get all Transmission records $query = "SELECT * FROM servifce_info WHERE issues_reported='Transmission'"; }elseif($_POST['value'] == 'Differential') { // query to get all Differential records $query = "SELECT * FROM servifce_info WHERE issues_reported='Differential'"; }elseif($_POST['value'] == 'Electrical') { // query to get all Electrical records $query = "SELECT * FROM servifce_info WHERE issues_reported='Electrical'"; }elseif($_POST['value'] == 'Tires') { // query to get all Tires records $query = "SELECT * FROM servifce_info WHERE issues_reported='Tires'"; }elseif($_POST['value'] == 'Brakes') { // query to get all Brakes records $query = "SELECT * FROM servifce_info WHERE issues_reported='Brakes'"; }elseif($_POST['value'] == 'HVAC') { // query to get all HVAC records $query = "SELECT * FROM servifce_info WHERE issues_reported='HVAC'"; }elseif($_POST['value'] == 'Lighting') { // query to get all Lighting records $query = "SELECT * FROM servifce_info WHERE issues_reported='Lighting'"; }elseif($_POST['value'] == 'Accident Damage') { // query to get all Accident Damage records $query = "SELECT * FROM servifce_info WHERE issues_reported='Accident Damage'"; } else { // query to get all records $query = "SELECT * FROM servifce_info "; } mysql_close(); } ?> <html> <head></head> <body> <form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='post' name='form_filter' > <select name="value"> <option value="all">All</option> <option value="Engine">Engine</option> <option value="Transmission">Transmission</option> <option value="Differential">Differential</option> <option value="Electrical">Electrical</option> <option value="Tires">Tires</option> <option value="Brakes">Brakes</option> <option value="HVAC">HVAC</option> <option value="Lighting">Lighting</option> <option value="Accident">Accident</option> </select> <br /> <input type='submit' value = 'Filter'> </form> <div id="nav"> <ul> <li><a href="order_vehicle_name.php" title=""> ORDER BY VEHICLE NAME</a></li> <li><a href="order_vehicle_number.php" title=""> ORDER BY VEHICLE NUMBER</a></li> <li><a href="order_location.php" title=""> ORDER BY LOCATION</a></li> <li><a href="order_status.php" title=""> ORDER BY STATUS</a></li> <li><a href="order_issues_reported.php" title=""> ORDER REPORTED ISSUES</a></li> <li><a href="order_id.php" title=""> ORDER BY ID</a></li> <li><a href="index.php">LOG OUT</a></li> </ul> </div> <table border="1" cellspacing="5" cellpadding="5"> <tr> <th><font face="Arial, Helvetica, sans-serif">ID</font></th> <th><font face="Arial, Helvetica, sans-serif">Vehicle Name</font></th> <th><font face="Arial, Helvetica, sans-serif">Vehicle Number</font></th> <th><font face="Arial, Helvetica, sans-serif">Location</font></th> <th><font face="Arial, Helvetica, sans-serif">Status</font></th> <th><font face="Arial, Helvetica, sans-serif">RTS</font></th> <th><font face="Arial, Helvetica, sans-serif">Odometer Date</font></th> <th><font face="Arial, Helvetica, sans-serif">Odometer Reading Date</font></th> <th><font face="Arial, Helvetica, sans-serif">Date of next scheduled maintenance</font></th> <th><font face="Arial, Helvetica, sans-serif">Maintenace/Repair Issues Reported</font></th> <th><font face="Arial, Helvetica, sans-serif">Date Issues Reported</font></th> <th><font face="Arial, Helvetica, sans-serif">Scheduled Service Date Issues Reported</font></th> <th><font face="Arial, Helvetica, sans-serif">Repair Service Performed W/Comments</font></th> <th><font face="Arial, Helvetica, sans-serif">Date Service Performed</font></th> <th><font face="Arial, Helvetica, sans-serif">Date OF Follow-up</font></th> <th><font face="Arial, Helvetica, sans-serif">Service In Progress 0=NO 1=YES</font></th> <th><font face="Arial, Helvetica, sans-serif">Date Return To Use</font></th> <th><font face="Arial, Helvetica, sans-serif">Time Return Use</font></th> <th><font face="Arial, Helvetica, sans-serif">Nonrepaiable Issues Found W/Comments</font></th> <th><font face="Arial, Helvetica, sans-serif">Date Issues Found</font></th> <th><font face="Arial, Helvetica, sans-serif">Parts Cost</font></th> <th><font face="Arial, Helvetica, sans-serif">Hours Worked</font></th> <th><font face="Arial, Helvetica, sans-serif">Comments</font></th> <th><font face="Arial, Helvetica, sans-serif">Update</font></th> </tr> <?php $i=0; while ($i < $num) { $field1=mysql_result($result,$i,"id"); $field2=mysql_result($result,$i,"name"); $field3=mysql_result($result,$i,"number"); $field4=mysql_result($result,$i,"location"); $field5=mysql_result($result,$i,"status"); $field6=mysql_result($result,$i,"rts"); $field7=mysql_result($result,$i,"odomread"); $field8=mysql_result($result,$i,"odomdate"); $field9=mysql_result($result,$i,"date_next_maint"); $field10=mysql_result($result,$i,"issues_reported"); $field11=mysql_result($result,$i,"date_reported"); $field12=mysql_result($result,$i,"scheduled_service_date"); $field13=mysql_result($result,$i,"service_performed"); $field14=mysql_result($result,$i,"date_service_performed"); $field15=mysql_result($result,$i,"date_of_followup"); $field16=mysql_result($result,$i,"service_in_progress"); $field17=mysql_result($result,$i,"date_return_use"); $field18=mysql_result($result,$i,"time_return_use"); $field19=mysql_result($result,$i,"issues_nonrepairable"); $field20=mysql_result($result,$i,"date_nonrepairable_issues"); $field21=mysql_result($result,$i,"parts_cost"); $field22=mysql_result($result,$i,"hours"); $field23=mysql_result($result,$i,"comments"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field1; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field2; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field3; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field4; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field5; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field6; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field7; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field8; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field9; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field10; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field11; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field12; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field13; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field14; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field15; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field16; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field17; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field18; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field19; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field20; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field21; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field22; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field23; ?></font></td> <td><a href="maint_update.php?id=<? echo $rows['id']; ?>">update</a></td> </tr> <?php $i++; } ?> </body> </html> I realize the id is blank because there is no id in the url but I don't see anything wrong in my code that is causing no id to be in the url.
  3. I understand why the query would fail with a blank id, I don't understand why the id is blank.
  4. Yes I see that problem, but I don't understand why it isn't getting the id of selected row to update.
  5. I am still getting the same error Maintenance Info Creation Failed. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5 Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5 SQL: UPDATE service_info SET `date_next_maint`='testing', `issues_reported`='', `date_reported`='', `scheduled_service_date`='', `service_performed`='', `date_service_performed`='', `date_of_followup`='',`service_in_progress`='', `date_return_use`='', `time_return_use`='', `issues_nonrepairable`='', `date_nonrepairable_issues`='', `comments` ='' WHERE id= No there is no id in the url Url- maint_update.php?id= Should I repost all 3 of the updated files that I have?
  6. I keep adapting my code with all the advice I get, when I get new errors I update to let everyone know the new error. What more information do you need? Let me know what more you need and I will gladly give it. Thank You
  7. I thought I defined id, here is the code I updated after your post. <?php require_once("dbcon.php"); ?> <?php require_once("functions.php"); ?> <?php $id=$_GET['id']; $date_next_maint = mysql_prep($_POST['date_next_maint']); $issues_reported = mysql_prep($_POST['issues_reported']); $date_reported = mysql_prep($_POST['date_reported']); $scheduled_service_date = mysql_prep($_POST['scheduled_service_date']); $service_performed = mysql_prep($_POST['service_performed']); $date_service_performed = mysql_prep($_POST['date_service_performed']); $date_of_followup = mysql_prep($_POST['date_of_followup']); $service_in_progress = mysql_prep($_POST['service_in_progress']); $date_return_use = mysql_prep($_POST['date_return_use']); $time_return_use = mysql_prep($_POST['time_return_use']); $issues_nonrepairable = mysql_prep($_POST['issues_nonrepairable']); $date_nonrepairable_issues = mysql_prep($_POST['date_nonrepairable_issues']); $comments = mysql_prep($_POST['comments']); ?> <?php $query = "UPDATE service_info SET `date_next_maint`='$date_next_maint', `issues_reported`='$issues_reported', `date_reported`='$date_reported', `scheduled_service_date`='$scheduled_service_date', `service_performed`='$service_performed', `date_service_performed`='$date_service_performed', `date_of_followup`='$date_of_followup',`service_in_progress`='$service_in_progress', `date_return_use`='$date_return_use', `time_return_use`='$time_return_use', `issues_nonrepairable`='$issues_nonrepairable', `date_nonrepairable_issues`='$date_nonrepairable_issues', `comments` ='$comments' WHERE id=$id"; $result = mysql_query($query, $connection); if ($result) { // Success! redirect_to("service_list_update.php"); } else { // Display error message. echo "<p>Maintenance Info Creation Failed.</p>"; echo "<p>" . mysql_error() . "</p>"; } echo "<p>Error: " . mysql_error() . " SQL: $query</p>"; ?>
  8. I did the echo you suggested and this is what I got Maintenance Info Creation Failed. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5 Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5 SQL: UPDATE service_info SET `date_next_maint`='testing', `issues_reported`='', `date_reported`='', `scheduled_service_date`='', `service_performed`='', `date_service_performed`='', `date_of_followup`='',`service_in_progress`='', `date_return_use`='', `time_return_use`='', `issues_nonrepairable`='', `date_nonrepairable_issues`='', `comments` ='' WHERE id=
  9. Sorry you are right I pasted the wrong file, this is the right file and I am getting this error <?php require_once("dbcon.php"); ?> <?php require_once("functions.php"); ?> <?php $date_next_maint = mysql_prep($_POST['date_next_maint']); $issues_reported = mysql_prep($_POST['issues_reported']); $date_reported = mysql_prep($_POST['date_reported']); $scheduled_service_date = mysql_prep($_POST['scheduled_service_date']); $service_performed = mysql_prep($_POST['service_performed']); $date_service_performed = mysql_prep($_POST['date_service_performed']); $date_of_followup = mysql_prep($_POST['date_of_followup']); $service_in_progress = mysql_prep($_POST['service_in_progress']); $date_return_use = mysql_prep($_POST['date_return_use']); $time_return_use = mysql_prep($_POST['time_return_use']); $issues_nonrepairable = mysql_prep($_POST['issues_nonrepairable']); $date_nonrepairable_issues = mysql_prep($_POST['date_nonrepairable_issues']); $comments = mysql_prep($_POST['comments']); ?> <?php $query = "UPDATE service_info SET `date_next_maint`='$date_next_maint', `issues_reported`='$issues_reported', `date_reported`='$date_reported', `scheduled_service_date`='$scheduled_service_date', `service_performed`='$service_performed', `date_service_performed`='$date_service_performed', `date_of_followup`='$date_of_followup',`service_in_progress`='$service_in_progress', `date_return_use`='$date_return_use', `time_return_use`='$time_return_use', `issues_nonrepairable`='$issues_nonrepairable', `date_nonrepairable_issues`='$date_nonrepairable_issues', `comments` ='$comments' WHERE id=$id"; $result = mysql_query($query, $connection); if ($result) { // Success! redirect_to("service_list_update.php"); } else { // Display error message. echo "<p>Maintenance Info Creation Failed.</p>"; echo "<p>" . mysql_error() . "</p>"; } ?> Error - Maintenance Info Creation Failed. Unknown column '$id' in 'where clause'
  10. Unless I'm missing something, the OP doesn't want to update all entries. That's why we suggested the WHERE clause be added. Yes you are right, I only want to update the selected record. Here is the updated code I have for the update page and the error I am now getting. <?php require_once("dbcon.php"); ?> <?php require_once("functions.php"); ?> <?php $date_next_maint = mysql_prep($_POST['date_next_maint']); $issues_reported = mysql_prep($_POST['issues_reported']); $date_reported = mysql_prep($_POST['date_reported']); $scheduled_service_date = mysql_prep($_POST['scheduled_service_date']); $service_performed = mysql_prep($_POST['service_performed']); $date_service_performed = mysql_prep($_POST['date_service_performed']); $date_of_followup = mysql_prep($_POST['date_of_followup']); $service_in_progress = mysql_prep($_POST['service_in_progress']); $date_return_use = mysql_prep($_POST['date_return_use']); $time_return_use = mysql_prep($_POST['time_return_use']); $issues_nonrepairable = mysql_prep($_POST['issues_nonrepairable']); $date_nonrepairable_issues = mysql_prep($_POST['date_nonrepairable_issues']); $comments = mysql_prep($_POST['comments']); ?> <?php $query = "UPDATE service_info SET `date_next_maint`='$date_next_maint', `issues_reported`='$issues_reported', `date_reported`='$date_reported', `scheduled_service_date`='$scheduled_service_date', `service_performed`='$service_performed', `date_service_performed`='$date_service_performed', `date_of_followup`='$date_of_followup',`service_in_progress`='$service_in_progress', `date_return_use`='$date_return_use', `time_return_use`='$time_return_use', `issues_nonrepairable`='$issues_nonrepairable', `date_nonrepairable_issues`='$date_nonrepairable_issues', `comments` ='$comments' WHERE id='$id'"; $result = mysql_query($query, $connection); if ($result) { // Success! redirect_to("service_list_update.php"); } else { // Display error message. echo "<p>Maintenance Info Creation Failed.</p>"; echo "<p>" . mysql_error() . "</p>"; } ?> Error - Parse error: syntax error, unexpected '(' in /data/9/0/28/4/517493/user/528148/htdocs/jednewdb/updated_maint.php on line 19
  11. Hello I have created a MySQL database and tables with vehicle information and maintenance information. I have added an update link in the table output, so maintenance information can be updated. I click the link and it takes me to the maintenance html form I created. when I hit submit I have it sending to the update script. It updates all the records not just the record I selected update on. Here is the code for my table output page where I have the option to update a record. Could the problem be here? Here is the code I have for the pages involved. Form Page: <?php require_once("dbcon.php"); ?> <?php require_once("functions.php"); ?> <?php // get value of id that sent from address bar $id=$_GET['id']; // Retrieve data from database $sql="SELECT * FROM $tbl_name WHERE id='$id'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); ?> <html> <body> <h1>Maintenace Report </h1> <section> <section> <form method="post" name="form1" action="updated_maint.php"> <table align="center"> <tr valign="baseline"> <th nowrap align="right">Date of next scheduled maintenance:</th> <td> <input type="text" name="date_next_maint" value="" size="32"> </tr> <tr valign="baseline"> <th nowrap align="right">Maintenace/Repair Issues Reported:</th> <td> <textarea name="issues_reported" rows="3" cols="27"></textarea> </tr> <tr valign="baseline"> <th nowrap align="right">Date That Maintenace/Repair Issues Reported:</th> <td> <input type="text" name="date_reported" value="" size="32"> </tr> <tr valign="baseline"> <th nowrap align="right">Scheduled Service Date That Maintenace/Repair Issues Reported:</th> <td> <input type="text" name="scheduled_service_date" value="" size="32"> </tr> <tr valign="baseline"> <th nowrap align="right">Maintenace/Repair Service Performed W/Comments:</th> <td> <textarea name="service_performed" rows="3" cols="27"></textarea> </tr> <tr valign="baseline"> <th nowrap align="right">Date Maintenace/Repair Service Performed:</th> <td><input type="text" name="date_service_performed" value="" size="32"></td> </tr> <tr valign="baseline"> <th nowrap align="right">Date OF Follow-up Work / If Needed:</th> <td> <input type="text" name="date_of_followup" value="" size="32"> </tr> <tr valign="baseline"> <th nowrap align="right">Service In Progress:</th> <td> <input type="radio" name="service_in_progress" value="0" /> No <input type="radio" name="service_in_progress" value="1" /> Yes </tr> <tr valign="baseline"> <th nowrap align="right">Date Return To Use:</th> <td> <input type="text" name="date_return_use" value="" size="32"> </tr> <tr valign="baseline"> <th nowrap align="right">Time Return Use:</th> <td> <input type="text" name="time_return_use" value="" size="32"> </tr> <tr valign="baseline"> <th nowrap align="right">Nonrepaiable Issues Found W/Comments:</th> <td> <textarea name="issues_nonrepairable" rows="3" cols="27"></textarea> </tr> <tr valign="baseline"> <th nowrap align="right">Date Nonrepaiable Issues Found:</th> <td> <input type="text" name="date_nonrepairable_issues" value="" size="32"> </tr> <tr valign="baseline"> <th nowrap align="right">Comments:</th> <td> <textarea name="comments" rows="3" cols="27"></textarea> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input type="submit" value="Insert record"></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1"> </form> <a href="maint_list_update.php">Cancel</a> <p> </p> </section> <!-- end .content --></h2> </section> </body> </html> Update Page: <?php require_once("dbcon.php"); ?> <?php require_once("functions.php"); ?> <?php $date_next_maint = mysql_prep($_POST['date_next_maint']); $issues_reported = mysql_prep($_POST['issues_reported']); $date_reported = mysql_prep($_POST['date_reported']); $scheduled_service_date = mysql_prep($_POST['scheduled_service_date']); $service_performed = mysql_prep($_POST['service_performed']); $date_service_performed = mysql_prep($_POST['date_service_performed']); $date_of_followup = mysql_prep($_POST['date_of_followup']); $service_in_progress = mysql_prep($_POST['service_in_progress']); $date_return_use = mysql_prep($_POST['date_return_use']); $time_return_use = mysql_prep($_POST['time_return_use']); $issues_nonrepairable = mysql_prep($_POST['issues_nonrepairable']); $date_nonrepairable_issues = mysql_prep($_POST['date_nonrepairable_issues']); $comments = mysql_prep($_POST['comments']); ?> <?php $query = "UPDATE service_info SET `date_next_maint`='$date_next_maint', `issues_reported`='$issues_reported', `date_reported`='$date_reported', `scheduled_service_date`='$scheduled_service_date', `service_performed`='$service_performed', `date_service_performed`='$date_service_performed', `date_of_followup`='$date_of_followup',`service_in_progress`='$service_in_progress', `date_return_use`='$date_return_use', `time_return_use`='$time_return_use', `issues_nonrepairable`='$issues_nonrepairable', `date_nonrepairable_issues`='$date_nonrepairable_issues', `comments` ='$comments'"; $result = mysql_query($query, $connection); if ($result) { // Success! redirect_to("maint_list_update.php"); } else { // Display error message. echo "<p>Maintenance Info Creation Failed.</p>"; echo "<p>" . mysql_error() . "</p>"; } ?> Update Record Page - <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Service Order Database</title> <link href="nav.css" rel="stylesheet" type="text/css"><!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <?php require_once("dbcon.php"); ?> <?php require_once("functions.php"); ?> <?php $query="SELECT * FROM service_info ORDER BY id"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; // process form when posted if(isset($_POST['value'])) { if($_POST['value'] == 'Engine') { // query to get all Engine records $query = "SELECT * FROM servifce_info WHERE issues_reported='Engine'"; }elseif($_POST['value'] == 'Transmission') { // query to get all Transmission records $query = "SELECT * FROM servifce_info WHERE issues_reported='Transmission'"; }elseif($_POST['value'] == 'Differential') { // query to get all Differential records $query = "SELECT * FROM servifce_info WHERE issues_reported='Differential'"; }elseif($_POST['value'] == 'Electrical') { // query to get all Electrical records $query = "SELECT * FROM servifce_info WHERE issues_reported='Electrical'"; }elseif($_POST['value'] == 'Tires') { // query to get all Tires records $query = "SELECT * FROM servifce_info WHERE issues_reported='Tires'"; }elseif($_POST['value'] == 'Brakes') { // query to get all Brakes records $query = "SELECT * FROM servifce_info WHERE issues_reported='Brakes'"; }elseif($_POST['value'] == 'HVAC') { // query to get all HVAC records $query = "SELECT * FROM servifce_info WHERE issues_reported='HVAC'"; }elseif($_POST['value'] == 'Lighting') { // query to get all Lighting records $query = "SELECT * FROM servifce_info WHERE issues_reported='Lighting'"; }elseif($_POST['value'] == 'Accident Damage') { // query to get all Accident Damage records $query = "SELECT * FROM servifce_info WHERE issues_reported='Accident Damage'"; } else { // query to get all records $query = "SELECT * FROM servifce_info "; } mysql_close(); } ?> <html> <head></head> <body> <form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='post' name='form_filter' > <select name="value"> <option value="all">All</option> <option value="Engine">Engine</option> <option value="Transmission">Transmission</option> <option value="Differential">Differential</option> <option value="Electrical">Electrical</option> <option value="Tires">Tires</option> <option value="Brakes">Brakes</option> <option value="HVAC">HVAC</option> <option value="Lighting">Lighting</option> <option value="Accident">Accident</option> </select> <br /> <input type='submit' value = 'Filter'> </form> <div id="nav"> <ul> <li><a href="order_vehicle_name.php" title=""> ORDER BY VEHICLE NAME</a></li> <li><a href="order_vehicle_number.php" title=""> ORDER BY VEHICLE NUMBER</a></li> <li><a href="order_location.php" title=""> ORDER BY LOCATION</a></li> <li><a href="order_status.php" title=""> ORDER BY STATUS</a></li> <li><a href="order_issues_reported.php" title=""> ORDER REPORTED ISSUES</a></li> <li><a href="order_id.php" title=""> ORDER BY ID</a></li> <li><a href="index.php">LOG OUT</a></li> </ul> </div> <table border="1" cellspacing="5" cellpadding="5"> <tr> <th><font face="Arial, Helvetica, sans-serif">ID</font></th> <th><font face="Arial, Helvetica, sans-serif">Vehicle Name</font></th> <th><font face="Arial, Helvetica, sans-serif">Vehicle Number</font></th> <th><font face="Arial, Helvetica, sans-serif">Location</font></th> <th><font face="Arial, Helvetica, sans-serif">Status</font></th> <th><font face="Arial, Helvetica, sans-serif">RTS</font></th> <th><font face="Arial, Helvetica, sans-serif">Odometer Date</font></th> <th><font face="Arial, Helvetica, sans-serif">Odometer Reading Date</font></th> <th><font face="Arial, Helvetica, sans-serif">Date of next scheduled maintenance</font></th> <th><font face="Arial, Helvetica, sans-serif">Maintenace/Repair Issues Reported</font></th> <th><font face="Arial, Helvetica, sans-serif">Date Issues Reported</font></th> <th><font face="Arial, Helvetica, sans-serif">Scheduled Service Date Issues Reported</font></th> <th><font face="Arial, Helvetica, sans-serif">Repair Service Performed W/Comments</font></th> <th><font face="Arial, Helvetica, sans-serif">Date Service Performed</font></th> <th><font face="Arial, Helvetica, sans-serif">Date OF Follow-up</font></th> <th><font face="Arial, Helvetica, sans-serif">Service In Progress 0=NO 1=YES</font></th> <th><font face="Arial, Helvetica, sans-serif">Date Return To Use</font></th> <th><font face="Arial, Helvetica, sans-serif">Time Return Use</font></th> <th><font face="Arial, Helvetica, sans-serif">Nonrepaiable Issues Found W/Comments</font></th> <th><font face="Arial, Helvetica, sans-serif">Date Issues Found</font></th> <th><font face="Arial, Helvetica, sans-serif">Parts Cost</font></th> <th><font face="Arial, Helvetica, sans-serif">Hours Worked</font></th> <th><font face="Arial, Helvetica, sans-serif">Comments</font></th> <th><font face="Arial, Helvetica, sans-serif">Update</font></th> </tr> <?php $i=0; while ($i < $num) { $field1=mysql_result($result,$i,"id"); $field2=mysql_result($result,$i,"name"); $field3=mysql_result($result,$i,"number"); $field4=mysql_result($result,$i,"location"); $field5=mysql_result($result,$i,"status"); $field6=mysql_result($result,$i,"rts"); $field7=mysql_result($result,$i,"odomread"); $field8=mysql_result($result,$i,"odomdate"); $field9=mysql_result($result,$i,"date_next_maint"); $field10=mysql_result($result,$i,"issues_reported"); $field11=mysql_result($result,$i,"date_reported"); $field12=mysql_result($result,$i,"scheduled_service_date"); $field13=mysql_result($result,$i,"service_performed"); $field14=mysql_result($result,$i,"date_service_performed"); $field15=mysql_result($result,$i,"date_of_followup"); $field16=mysql_result($result,$i,"service_in_progress"); $field17=mysql_result($result,$i,"date_return_use"); $field18=mysql_result($result,$i,"time_return_use"); $field19=mysql_result($result,$i,"issues_nonrepairable"); $field20=mysql_result($result,$i,"date_nonrepairable_issues"); $field21=mysql_result($result,$i,"parts_cost"); $field22=mysql_result($result,$i,"hours"); $field23=mysql_result($result,$i,"comments"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field1; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field2; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field3; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field4; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field5; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field6; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field7; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field8; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field9; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field10; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field11; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field12; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field13; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field14; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field15; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field16; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field17; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field18; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field19; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field20; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field21; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field22; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $field23; ?></font></td> <td><a href="maint_update.php?id=<? echo $rows['id']; ?>">update</a></td> </tr> <?php $i++; } ?> </body> </html> Please help and a great thank you in advance.
  12. When I click the update button to It should populate a list of games I want that users have or a list of games I have that users want. But when I click it nothing is populated.
  13. Here is the coding I have so far on the potential trades page. First set of coding is a file that contains all my php functions and is included in all my php pages, second file is my php page that is not working correctly. Functions Coding <?php session_start(); $memberID = (isset($_SESSION['memberID']) ? $_SESSION['memberID'] : ''); $fName = (isset($_SESSION['fName']) ? $_SESSION['fName'] : ''); function logout(){ global $memberID; global $fName; $memberID = ''; $fName = ''; session_destroy(); session_start(); } function ensureLoggedIn(){ global $memberID; if($memberID == ''){ header("Location: logout.php"); } } function loginCheck($email, $password){ //Returns true if successful login, otherwise returns false. //Sets global variables about user if successful login. global $memberID; global $fName; //Clear all session vars; start new session. session_start(); $memberID = ''; $fName = ''; $encryptedPassword = ''; $encryptedPassword = crypt($password); $sql = "select ID, fName from tblmember where email = '$email' and (password = '$password' or password = '$encryptedPassword')"; $rs = getRecordset($sql, false); //2nd arg false to cause false to be returned if rs empty. if($rs === false){ return false; } $memberID = $rs->fields[0]; $fName = $rs->fields[1]; $_SESSION['memberID'] = $memberID; $_SESSION['fName'] = $fName; return true; } function registerNewMember($fN, $lN, $email, $pw, $street1, $street2, $city, $state, $country, $zip, $screenName){ //Returns true/false based on success. //Encrypt the password. $pw = crypt($pw); $sql = <<<STRSQL INSERT INTO tblmember(fName, lName, email, password, street1, street2, city, state, country, zip, screenName) VALUES('$fN', '$lN', '$email', '$pw', '$street1', '$street2', '$city', '$state', '$country', '$zip', '$screenName') STRSQL; return runActionQuery($sql); } function updateRegistrationData($fN, $lN, $email, $pw, $street1, $street2, $city, $state, $country, $zip, $screenName){ //Returns true/false based on success. global $memberID; //Encrypt the password. $pw = crypt($pw); $sql = <<<STRSQL UPDATE tblmember SET fName='$fN', lName='$lN', email='$email', password='$pw', street1='$street1', street2='$street2', city='$city', state='$state', country='$country', zip='$zip', screenName='$screenName' WHERE ID = $memberID STRSQL; return runActionQuery($sql); } function getMyGamesList($htmlID, $visibleListItemsCount = 15, $displayDelimiter = '-'){ //Returns a string containing an html select tag (listbox) of the games listing for the current user. //Pass in $htmlID so that tag is built with html id for css etc. global $memberID; //Recall, we must not show traded games in the games list. $sql = <<<STRSQL select g.ID, g.gameTitle 'Game Title', p.platformName 'Platform', s.statusCode 'Status' from tblgame g inner join tblPlatform p on(p.ID = g.platformID) inner join tblGameStatusCode s on(s.ID = g.gameStatusCode) where g.memberID = $memberID and s.ID <> 3 STRSQL; $rs = getRecordset($sql); if($rs === false){ return ''; } return htmlSelectTagFromRecordset($rs, $htmlID, $visibleListItemsCount, $displayDelimiter); } function addGame_InsertGameRecord($gameTitle, $platformID, $gameStatusCode){ global $memberID; $platformID = getIDValIfNotNumeric($platformID); $gameStatusCode = getIDValIfNotNumeric($gameStatusCode); $sql = <<<STRSQL INSERT INTO tblgame(gameTitle, platformID, memberID, gameStatusCode) VALUES('$gameTitle', $platformID, $memberID, $gameStatusCode) STRSQL; $boolSuccess = runActionQuery($sql); if($boolSuccess){ return("'$gameTitle' successfully added."); }else{ return("Failed to add '$gameTitle'."); } } function addGame_GetPlatformDropDown($htmlID){ $sql = <<<STRSQL select ID, platformName from tblPlatform order by platformName STRSQL; $rs = getRecordset($sql); if($rs === false){ return ''; } return htmlSelectTagFromRecordset($rs, $htmlID, 1); } function addGame_GetGameStatusCodeDropDown($htmlID){ $sql = <<<STRSQL select ID, statusCode from tblGameStatusCode where ID <> 3 order by statusCode STRSQL; $rs = getRecordset($sql); if($rs === false){ return ''; } return htmlSelectTagFromRecordset($rs, $htmlID, 1); } function deleteGame($gameID){ global $memberID; $gameID = getIDValIfNotNumeric($gameID); $sql = <<<STRSQL delete from tblGame where ID = $gameID and memberID = $memberID STRSQL; return runActionQuery($sql); } function myCompletedTrades_TransactionsDropDown($transID, $htmlID, $displayDelimiter = '-'){ //Returns a string containing an html select tag (drop down) (ID | TradeDate | TradedWith) for the current user. //Pass in $htmlID so that tag is built with html id for css etc. global $memberID; $transID = getIDValIfNotNumeric($transID); $sql = <<<STRSQL select t.ID, DATE_FORMAT(t.dateFinalized,'%c/%e/%Y') "Trade Date", m.screenName "Traded With" from tblTransaction t inner join tblTransactionParty tp1 on(t.ID = tp1.transID) inner join tblTransactionParty tp2 on(t.ID = tp2.transID) inner join tblMember m on(m.ID = tp2.memberID) where tp1.memberID = $memberID and tp2.memberID <> $memberID and t.dateFinalized is not null order by t.dateFinalized STRSQL; $rs = getRecordset($sql); if($rs === false){ return ''; } return htmlSelectTagFromRecordset($rs, $htmlID, 1, $displayDelimiter, $transID); } function myCompletedTrades_GamesIGaveListBox($transID, $htmlID, $visibleItemsCount = 8, $displayDelimiter = '-'){ global $memberID; $transID = getIDValIfNotNumeric($transID); $sql = <<<STRSQL select g.ID, g.gameTitle, p.platformName from tblTransactionDetail td inner join tblGame g on(g.ID = td.gameID) inner join tblPlatform p on(p.ID = g.platformID) where td.transID = $transID and g.memberID = $memberID STRSQL; $rs = getRecordset($sql); if($rs === false){ return ''; } return htmlSelectTagFromRecordset($rs, $htmlID, $visibleItemsCount, $displayDelimiter); } function myCompletedTrades_GamesIGotListBox($transID, $htmlID, $visibleItemsCount = 8, $displayDelimiter = '-'){ global $memberID; $transID = getIDValIfNotNumeric($transID); $sql = <<<STRSQL select g.ID, g.gameTitle, p.platformName from tblTransactionDetail td inner join tblGame g on(g.ID = td.gameID) inner join tblPlatform p on(p.ID = g.platformID) where td.transID = $transID and g.memberID <> $memberID STRSQL; $rs = getRecordset($sql); if($rs === false){ return ''; } return htmlSelectTagFromRecordset($rs, $htmlID, $visibleItemsCount, $displayDelimiter); } function myCompletedTrades_sendGamesToAddressText($transID){ global $memberID; $transID = getIDValIfNotNumeric($transID); $sql = <<<STRSQL select concat(m.fName, " ", m.LName, "\n", m.street1, "\n", ifnull(m.street2, ""), "\n", m.city, ", ", m.state, " ", m.zip, "\n", m.country) "sendToAddress" from tblTransactionParty tp inner join tblMember m on(m.ID = tp.memberID) where tp.transID = $transID and tp.memberID <> $memberID STRSQL; $rs = getRecordset($sql); if($rs === false){ return ''; } return $rs->fields[0]; } function myCompletedTrades_ratingOfMemberDropDown($transID){ global $memberID; $transID = getIDValIfNotNumeric($transID); $rating = ''; $sql = <<<STRSQL select tp.rating from tblTransactionParty tp where tp.transID = $transID and tp.memberID <> $memberID STRSQL; $rs = getRecordset($sql); if($rs !== false && $rs->EOF == false){ $rating = $rs->fields[0]; } switch($rating){ case 'low': $selLow = 'selected'; $selAvg = ''; $selHigh = ''; break; case 'average': $selLow = ''; $selAvg = 'selected'; $selHigh = ''; break; case 'high': $selLow = ''; $selAvg = ''; $selHigh = 'selected'; break; default: $selLow = ''; $selAvg = ''; $selHigh = ''; break; } $strDropDown = <<<STRDROP <select> <option value="low" selected="$selLow">low</option> <option value="average" selected="$selAvg">average</option> <option value="high" selected="$selHigh">high</option> </select> STRDROP; return $strDropDown; } function myCompletedTrades_commentOnMemberTradedWith($transID){ global $memberID; $transID = getIDValIfNotNumeric($transID); $sql = <<<STRSQL select tp.comment from tblTransactionParty tp where tp.transID = $transID and tp.memberID <> $memberID STRSQL; $rs = getRecordset($sql); if($rs === false){ return ''; } if(is_null($rs->fields[0]) == false){ return $rs->fields[0]; }else{ return ''; } } function myCompletedTrades_saveRatingAndComment($transID, $rating, $comment){ global $memberID; $transID = getIDValIfNotNumeric($transID); $sql = <<<STRSQL update tblTransactionParty set rating = '$rating', comment = '$comment' where transID = $transID and memberID <> $memberID STRSQL; return runActionQuery($sql); } function viewMyFeedbackRatingsComments($htmlID, $visibleItemsCount = 20, $displayDelimiter = '-'){ global $memberID; $sql = <<<STRSQL select DATE_FORMAT(t.dateFinalized,'%c/%e/%Y') "Transaction Date", tp.rating "Rating", tp.comment "Comment" from tblTransaction t inner join tblTransactionParty tp on(tp.transID = t.ID) where t.dateFinalized is not null and tp.memberID = $memberID order by t.dateFinalized STRSQL; $rs = getRecordset($sql); if($rs === false){ return ''; } return htmlSelectTagFromRecordset($rs, $htmlID, $visibleItemsCount, $displayDelimiter); } function potentialTrades_ScreenNamesDropDown_ShowAll($htmlID, $selectedMemberID = -1){ global $memberID; $sql = <<<STRSQL select b.screenName from tblMember b where b.ID <> $memberID order by b.screenName STRSQL; $rs = getRecordset($sql); if($rs === false){ return ''; } return htmlSelectTagFromRecordset($rs, $htmlID, 1, '', $selectedMemberID); } function potentialTrades_ScreenNamesDropDown_ShowPeopleWithGamesIWant($htmlID, $selectedMemberID = -1){ global $memberID; $sql = <<<STRSQL select m.screenName from tblGame avail inner join tblGame want on(want.platformID = avail.platformID and upper(want.gameTitle) = upper(avail.gameTitle)) inner join tblMember m on(m.ID = avail.memberID) where avail.gameStatusCode = 1 and want.gameStatusCode = 2 and avail.memberID <> $memberID and want.memberID = $memberID order by m.screenName STRSQL; $rs = getRecordset($sql); if($rs === false){ return ''; } return htmlSelectTagFromRecordset($rs, $htmlID, 1, '', $selectedMemberID); } function potentialTrades_ScreenNamesDropDown_ShowPeopleWantingMyGames($htmlID, $selectedMemberID = -1){ global $memberID; $sql = <<<STRSQL select m.screenName from tblGame avail inner join tblGame want on(want.platformID = avail.platformID and upper(want.gameTitle) = upper(avail.gameTitle)) inner join tblMember m on(m.ID = want.memberID) where avail.gameStatusCode = 1 and want.gameStatusCode = 2 and avail.memberID = $memberID and want.memberID <> $memberID order by m.screenName STRSQL; $rs = getRecordset($sql); if($rs === false){ return ''; } return htmlSelectTagFromRecordset($rs, $htmlID, 1, '', $selectedMemberID); } function potentialTrades_ScreenNamesDropDown_ShowPeopleIAmNegotiatingWith($htmlID, $selectedMemberID = -1){ global $memberID; $sql = <<<STRSQL select m.screenName from tblTransaction t inner join tblTransactionParty tp1 on(tp1.transID = t.ID) inner join tblTransactionParty tp2 on(tp2.transID = t.ID) inner join tblMember m on(m.ID = tp1.memberID) where t.dateFinalized is null and tp1.memberID <> $memberID and tp2.memberID = $memberID order by m.screenName STRSQL; $rs = getRecordset($sql); if($rs === false){ return ''; } return htmlSelectTagFromRecordset($rs, $htmlID, 1, '', $selectedMemberID); } function potentialTrades_GamesTheyWantListBox($selectedMemberID, $htmlID, $visibleListItemsCount = 10, $displayDelimiter = '-'){ $selectedMemberID = getIDValIfNotNumeric($selectedMemberID); $sql = <<<STRSQL select g.ID, g.gameTitle 'Game Title', p.platformName 'Platform' from tblgame g inner join tblPlatform p on(p.ID = g.platformID) where g.memberID = $selectedMemberID and g.gameStatusCode = 2 STRSQL; $rs = getRecordset($sql); if($rs === false){ return ''; } return htmlSelectTagFromRecordset($rs, $htmlID, $visibleListItemsCount, $displayDelimiter); } function potentialTrades_GamesIWantListBox($htmlID, $visibleListItemsCount = 10, $displayDelimiter = '-'){ global $memberID; $sql = <<<STRSQL select g.ID, g.gameTitle 'Game Title', p.platformName 'Platform' from tblgame g inner join tblPlatform p on(p.ID = g.platformID) where g.memberID = $memberID and g.gameStatusCode = 2 STRSQL; $rs = getRecordset($sql); if($rs === false){ return ''; } return htmlSelectTagFromRecordset($rs, $htmlID, $visibleListItemsCount, $displayDelimiter); } function potentialTrades_GamesIHaveListBox($htmlID, $visibleListItemsCount = 10, $displayDelimiter = '-'){ global $memberID; $sql = <<<STRSQL select g.ID, g.gameTitle 'Game Title', p.platformName 'Platform' from tblgame g inner join tblPlatform p on(p.ID = g.platformID) where g.memberID = $memberID and g.gameStatusCode = 1 STRSQL; $rs = getRecordset($sql); if($rs === false){ return ''; } return htmlSelectTagFromRecordset($rs, $htmlID, $visibleListItemsCount, $displayDelimiter); } function potentialTrades_GamesTheyHaveListBox($selectedMemberID, $htmlID, $visibleListItemsCount = 10, $displayDelimiter = '-'){ $selectedMemberID = getIDValIfNotNumeric($selectedMemberID); $sql = <<<STRSQL select g.ID, g.gameTitle 'Game Title', p.platformName 'Platform' from tblgame g inner join tblPlatform p on(p.ID = g.platformID) where g.memberID = $selectedMemberID and g.gameStatusCode = 1 STRSQL; $rs = getRecordset($sql); if($rs === false){ return ''; } return htmlSelectTagFromRecordset($rs, $htmlID, $visibleListItemsCount, $displayDelimiter); } function potentialTrades_GamesIWillGiveListBox($selectedMemberID, $htmlID, $visibleListItemsCount = 10, $displayDelimiter = '-'){ global $memberID; $selectedMemberID = getIDValIfNotNumeric($selectedMemberID); $sql = <<<STRSQL select g.ID, g.gameTitle 'Game Title', p.platformName 'Platform' from tblTransactionParty tp1 inner join tblTransactionParty tp2 on(tp2.transID = tp1.transID and tp2.memberID <> tp1.memberID) innter join tblTransactionDetail td on(td.transID = tp1.transID) inner join tblgame g(on g.ID = td.gameID) inner join tblPlatform p on(p.ID = g.platformID) inner join tblTransaction t on(t.ID = tp1.transID) where tp1.memberID = $memberID and tp2.memberID = $selectedMemberID and g.gameStatusCode = 1 and t.dateFinalized is null STRSQL; $rs = getRecordset($sql); if($rs === false){ return ''; } return htmlSelectTagFromRecordset($rs, $htmlID, $visibleListItemsCount, $displayDelimiter); } function potentialTrades_GamesIWillGetListBox($selectedMemberID, $htmlID, $visibleListItemsCount = 10, $displayDelimiter = '-'){ global $memberID; $selectedMemberID = getIDValIfNotNumeric($selectedMemberID); $sql = <<<STRSQL select g.ID, g.gameTitle 'Game Title', p.platformName 'Platform' from tblTransactionParty tp1 inner join tblTransactionParty tp2 on(tp2.transID = tp1.transID and tp2.memberID <> tp1.memberID) innter join tblTransactionDetail td on(td.transID = tp1.transID) inner join tblgame g(on g.ID = td.gameID) inner join tblPlatform p on(p.ID = g.platformID) inner join tblTransaction t on(t.ID = tp1.transID) where tp1.memberID = $selectedMemberID and tp2.memberID = $memberID and g.gameStatusCode = 1 and t.dateFinalized is null STRSQL; $rs = getRecordset($sql); if($rs === false){ return ''; } return htmlSelectTagFromRecordset($rs, $htmlID, $visibleListItemsCount, $displayDelimiter); } function unfinalizedTransIDFromMemberID($selectedMemberID){ global $memberID; $selectedMemberID = getIDValIfNotNumeric($selectedMemberID); if($selectedMemberID == -1){ return -1; } $sql = <<<STRSQL select t.ID from tblTransactionParty tp1 inner join tblTransactionParty tp2 on(tp2.transID = tp1.transID and tp2.memberID <> tp1.memberID) inner join tblTransaction t on(t.ID = tp1.transID) where tp1.memberID = $selectedMemberID and tp2.memberID = $memberID and t.dateFinalized is null STRSQL; $rs = getRecordset($sql); if($rs === false || $rs->EOF == true){ return -1; } //We have a record. return $rs->fields[0]; } function potentialTrades_MakeOffer($selectedMemberID, $pipeDelimGameIDsToBeTraded){ global $memberID; $transID = -1; $sql = ''; $boolSuccess = true; $boolIsNewTrans = false; $selectedMemberID = getIDValIfNotNumeric($selectedMemberID); if($selectedMemberID == -1){ return 'Member not selected for making an offer.'; } //Trim away any leading or trailing pipe character(s). $pipeDelimGameIDsToBeTraded = trim($pipeDelimGameIDsToBeTraded,'|'); if($pipeDelimGameIDsToBeTraded == ''){ return 'No games have been specified to be made a part of the trade.'; } $transID = unfinalizedTransIDFromMemberID($selectedMemberID); if($transID == -1){ $boolIsNewTrans = true; }else{ $boolIsNewTrans = false; } beginTransaction(); //------- //Work with tblTransaction... switch($boolIsNewTrans){ case true: //No unfinalized transaction yet exists between logged in member and specified member. //Create new transaction record and get the ID of the newly created record. $sql = <<<STRSQL insert into tblTransaction(dateFinalized, changeCount) VALUES(null, 1) STRSQL; $boolSuccess = $boolSuccess && runActionQuery($sql); //Get ID of newly inserted record. $transID = lastInsertedID(); break; case false: //We have record of an unfinalized transaction in progress. Update the change count. $sql = <<<STRSQL update tblTransaction set changeCount = changeCount + 1 where ID = $transID STRSQL; $boolSuccess = $boolSuccess && runActionQuery($sql); break; } //------- //------- //Work with tblTransactionParty... switch($boolIsNewTrans){ case true: //Since new, add two records to tblTransactionParty; changeCountAccepted = 1 for logged in member, 0 for other member... //----For logged-in member: $sql = <<<STRSQL insert tblTransactionParty(transID, memberID, changeCountAccepted) values($transID, $memberID, 1) STRSQL; $boolSuccess = $boolSuccess && runActionQuery($sql); //---- //----For selected member: $sql = <<<STRSQL insert tblTransactionParty(transID, memberID, changeCountAccepted) values($transID, $selectedMemberID, 0) STRSQL; $boolSuccess = $boolSuccess && runActionQuery($sql); //---- break; case false: //Since existing, update tblTransactionParty just for the logged in member, setting changeCountAccepted to changeCount of trans. //---- $sql = <<<STRSQL update tblTransactionParty tp inner join tblTransaction t(on t.ID = tp.transID) set tp.changeCountAccepted = t.changeCount where t.ID = $transID and tp.memberID = $memberID STRSQL; $boolSuccess = $boolSuccess && runActionQuery($sql); //---- break; } //------- //------- //Work with tblTransactionDetail... switch($boolIsNewTrans){ case true: //do nothing at this time; only need to do inserts which is done below. break; case false: //if existing, delete all records in tblTransactionDetail for current trans. //---- $sql = <<<STRSQL delete from tblTransactionDetail where transID = $transID STRSQL; $boolSuccess = $boolSuccess && runActionQuery($sql); //---- break; } //Now add records to tblTransactionDetail using var $pipeDelimGameIDsToBeTraded $arrGameID = explode('|', $pipeDelimGameIDsToBeTraded); foreach($arrGameID as $gameID){ $sql = <<<STRSQL insert into tblTransactionDetail(transID, gameID) values($transID, $gameID) STRSQL; $boolSuccess = $boolSuccess && runActionQuery($sql); } //------- commitTransaction(); if($boolSuccess == true){ return 'Offer successfully made.'; }else{ return 'There was an error in the database work required for making the offer.'; } } function potentialTrades_RejectAndEndNegotiations($selectedMemberID){ global $memberID; $transID = -1; $sql = ''; $boolSuccess = true; $selectedMemberID = getIDValIfNotNumeric($selectedMemberID); if($selectedMemberID == -1){ return 'Member not selected.'; } $transID = unfinalizedTransIDFromMemberID($selectedMemberID); if($transID == -1){ return 'There is no transaction being negotiated with the selected member.'; } beginTransaction(); //------- //Work with tblTransactionDetail... $sql = <<<STRSQL delete from tblTransactionDetail where transID = $transID STRSQL; $boolSuccess = $boolSuccess && runActionQuery($sql); //------- //------- //Work with tblTransactionParty... $sql = <<<STRSQL delete from tblTransactionParty where transID = $transID STRSQL; $boolSuccess = $boolSuccess && runActionQuery($sql); //------- //------- //Work with tblTransaction... $sql = <<<STRSQL delete from tblTransaction where ID = $transID STRSQL; $boolSuccess = $boolSuccess && runActionQuery($sql); //------- commitTransaction(); if($boolSuccess == true){ return 'Negotiations successfully ended with the selected member.'; }else{ return 'There was an error in the database work required for ending the negotiations.'; } } function potentialTrades_AcceptOffer($selectedMemberID){ global $memberID; $transID = -1; $sql = ''; $boolSuccess = true; $rowCount = 0; $selectedMemberID = getIDValIfNotNumeric($selectedMemberID); if($selectedMemberID == -1){ return 'Member not selected for accepting an offer.'; } $transID = unfinalizedTransIDFromMemberID($selectedMemberID); if($transID == -1){ return 'There is no transaction being negotiated with the selected member.'; } //------- //Check that changeCountAccepted of the other party is equal to changeCount of trans (which tells us // that the other party was the last to make an offer). If it's not, notify cannot accept and get out. $sql = <<<STRSQL select count(tp.ID) from tblTransactionParty tp inner join tblTransaction t on(t.ID = tp.transID) where tp.transID = $transID and tp.memberID = $selectedMemberID and tp.changeCountAccepted = t.changeCount STRSQL; $rowCount = rowCountFromSelectCountSQL($sql); if($rowCount == 0){ //This means that the other party was not the last to make an offer; logged in user therefore //has no standing offer to accept. return 'The selected member was not the last one to make an offer; there is no standing offer for you to accept from this member; at this time, you can only make a revised offer.'; } //------- //------- //Get the count of games in the detail of this trans that are no longer marked as being available for trade // because they may have since been traded in a finalized transaction with a different member. $sql = <<<STRSQL delete from td using tblTransactionDetail td inner join tblGame g on(g.ID = td.gameID) where td.transID = $transID and g.gameStatusCode <> 1 STRSQL; $rowCount = -1; $boolSuccess = runActionQuery($sql, $rowCount); if($boolSuccess === false){ return 'There was an error verifying that all games associated with the transaction are still available; cannot accept transaction at this time.'; } if($rowCount > 0){ //There were games in the transaction which were no longer available and were deleted from the detail. //Increment trans changeCount to reflect this change so that the current user will be forced to make an offer. $sql = <<<STRSQL update tblTransaction set changeCount = ChangeCount + 1 where ID = $transID STRSQL; $boolSuccess = runActionQuery($sql); return 'There were games in this transaction which are no longer available; please refresh your view of this transaction and make a new offer or end negotiations.'; } //------- //------- //We could also check the pipe delim list of gameIDs that the logged in user is looking at and ensure //the exactly match all the game ID in the trans detail. If differs, would notify and get out. //But also, the interface should disable the Accept offer button if the user has modified the games in the trade. //------- //Prior to this point we have done validation to ensure the transaction can be accepted. beginTransaction(); $boolSuccess = true; //------- //Work with tblTransactionParty... //Update tblTransactionParty for the logged in member, setting changeCountAccepted to changeCount of trans. $sql = <<<STRSQL update tblTransactionParty tp inner join tblTransaction t(on t.ID = tp.transID) set tp.changeCountAccepted = t.changeCount where t.ID = $transID and tp.memberID = $memberID STRSQL; $boolSuccess = $boolSuccess && runActionQuery($sql); //------- //------- //Work with tblGame... //Mark all games involved in the transaction as traded. $sql = <<<STRSQL update tblGame g inner join tblTransactionDetail td on(g.ID = td.gameID) set g.gameStatusCode = 3 where td.transID = $transID STRSQL; $boolSuccess = $boolSuccess && runActionQuery($sql); //------- //------- //Work with tblTransaction... //Value column dateFinalized with the current date. $sql = <<<STRSQL update tblTransaction set dateFinalized = getdate() where ID = $transID STRSQL; $boolSuccess = $boolSuccess && runActionQuery($sql); //------- commitTransaction(); if($boolSuccess == true){ return 'Offer successfully accepted. After you receive your games from the other party, please leave a rating and comments on your trade experience with them.'; }else{ return 'There was an error in the database work required for accepting the offer.'; } } My Potential Trades Page: <!DOCTYPE HTML> <?php require_once('..\phpLib\dbConn.php'); require_once('..\phpLib\gamesTraderSQL.php'); ?> <html> <title>New To Me Games</title> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link href="../_css/main.css" rel="stylesheet" type="text/css"><!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <script type="text/javascript"> { document.getElementById('divOutput').innerHTML = window.location.search; } // Technique 1 function placeInHidden(delim, selStr, hidStr) { var selObj = document.getElementById(selStr); var hideObj = document.getElementById(hidStr); hideObj.value = ''; for (var i=0; i<selObj.options.length; i++) { hideObj.value = hideObj.value == '' ? selObj.options[i].value : hideObj.value + delim + selObj.options[i].value; } } // Technique 2 function selectAllOptions(selStr) { var selObj = document.getElementById(selStr); for (var i=0; i<selObj.options.length; i++) { selObj.options[i].selected = true; } } //--> </script> </head> <body> <div class="container"> <header> <a href="#"><img src="../_images/logo.png" alt="Insert Logo Here" name="Insert_logo" width="960" height="150" id="Insert_logo" style="background: #C6D580; display:block;" /></a> </header> <div class="sidebar1"> <nav> <ul> <li><a href="home.php" title="">HOME</a></li> </ul> </nav> <!-- end .sidebar1 --></div> <article class="content"> <h1>Potential Trades</h1> <section> <h2>Search For Games To Trade </h2> <div> </div> </p> <form name="form1" method="get" action=""> <p> <label> <input type="submit" name="Update" value="Update"> Users With Games I Want </label> <br> <label> <input type="submit" name="Update" value="Update"> Users That Want My Games</label> <br> </p> <p> <select name="Screen Name" size="1"></select> </p> </form> <div> <form name="form2" method="post" action=""> <label for="theyWant">Games They Want</label> <textarea name="theyWant" id="theyWant" cols="45" rows="5"></textarea> <label for="myGames">Games I Have</label> <textarea name="myGames" id="myGames" cols="45" rows="5"></textarea> <label for="wantedGames"><br> Games I Want</label> <textarea name="wantedGames" id="wantedGames" cols="45" rows="5"></textarea> <label for="thierGmaes">Games They Have</label> <textarea name="thierGmaes" id="thierGmaes" cols="45" rows="5"></textarea> <textarea name="textarea" id="textarea" cols="45" rows="5"></textarea> </form> </div> <p> <table width="598" border="0"> <tr> <td> Games I Will Give<br /> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" onsubmit="placeInHidden('.', 'sel3', 'hide2');"> <select id="sel3" multiple="multiple" size="5"> <option value="optDVal1">optDText1</option> <option value="optDVal2">optDText2</option> <option value="optDVal3">optDText3</option> </select> <input type="hidden" name="hide2Name" id="hide2" /> <br /> <input type="submit" value="Submit" /> </form> </td> <td align="center" valign="middle"> <form> <input type="button" value="-->" onclick="moveOptions(document.getElementById('sel3'), document.getElementById('sel4'));" /><br /> <input type="button" value="<--" onclick="moveOptions(document.getElementById('sel4'), document.getElementById('sel3'));" /> </form> </td> <td> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" onsubmit="selectAllOptions('sel4');"> Games I Will Get<br /> <select name="selPHP[]" id="sel4" multiple="multiple" size="5"> <option value="optCVal1">optCText1</option> <option value="optCVal2">optCText2</option> <option value="optCVal3">optCText3</option> </select> <br /> <input type="submit" value="Submit" /> </form> </td> </tr> </table> </p> </section> <!-- end .content --></article> <footer> <p> </p> </footer> <!-- end .container --></div> </body> </html>
  14. Hello I am making a game trading web application for class. Here are the requirements: You must be able to register and log in, you must be able to list games you have to trade and games you want, you must be able to search users that want games you have and users that have games you want, you must be able to accept and make trades, on trade finalization screen you must be able to rate user 1-5, view the users shipping address, and leave a comment on the users page. You do not have to be able to view other users pages, but on your home page you must be able to view your average rating. I am the most advanced programmer in my group so this has been a little tough. I have a login page and a registration page, I have a user home page, a add games page, a view feedback/ratings page, and a my games page where you can delete games. What I'm stuck on is the page that allows you to search users by games they want and games you want, and the trade finalization page. On the search page I would like to combine the functionality of searching for users with games you want and games they want with the ability to make a trade offer. The way we have it drawn up is using radio buttons to select either show people with games I want and show people wanting my games. When one is selected it will populate a list of usersnames in a drop down menu that fit whichever choice was made. We drew up four list boxes that populate lists when we select a user name, one box populates the games they have, one populates the games they want, one populates the games I have and one populates games I want. We want to be able to select game titles and move them to a list box of games I want and another to a list box of games willing to trade, lastly a submit offer button. We are debating on if this is the best set up given the requirements needing to be met. I think there is more here than what we need, we have 1 week to do this and I am doing all the programming so I am looking for the easiest way to search users that want games I have/have games I want and display the results giving me the option to select games to trade and make an offer. We are also arguing on if we have to use JavaScript to do this or if it can all be done within php. The trade finalization page would have a drop down menu where you select the user name of completed trades and upon selection lists will be populated of games they gave, games I gave and the address to send the game. It will also have a form where we can rate the user and leave a comment. This page I need help with cause again we disagree on having to use JavaScript or not. We are using phpMyAdmin and the db tables we have are: tblgame - list of games I have added tblgamestatuscode - gives game a code that determines if it is wanted, to trade, or traded tblmember - member registration tblplatform - platform the game is on (Xbox, Xbox 360, Playstation2, Playstation3, PC, and Wii) tbltransaction - date traded and a status change code tbltransactiondetail - gameID and trans ID tbltransactionparty - memberID, transID, rating, comments, status change accepted We are also using adodb. Please help if you can. I will gladly give more information if needed.
  15. Thank you, I am hoping to actually gain knowledge and not just get the answer right, from what I have researched there are amazing things that can be done with PHP. Knowing what the code does and seeing it like you have displayed helps me to learn how it functions. I will still need to edit it to get the information from the text area of the html page, cause they have to be separate pages, so please don't think I am just gonna steal your code and give no credit. Will this also work for any xml tag for example <age>30</age>, I just used <fname> and <lname> as examples. Again thank you for the help in understanding.
  16. Thank you that does help explain things a lot more. I have just found out another requirement on the output is row names for each value. For example: <fname>James</fname> <lname>White</lname> Will output: fname James lname White
  17. Ok I am a student and my instructor keeps giving us projects dealing with PHP coding even though only half our class has had a PHP server side scripting class. The project he just gave us I thought would be simple, but I'm still struggling to find online the proper scripting to get my php file to do what I need it to do. Requirements : Create a simple html page that contains a text area with a submit buton - DONE The submit button will call a php page and display the text typed in the text area - DONE Allow users to enter XML script into the text area and when submit button is clicked the php page will display the XML without the XML tags, Example - Text Area Entry Would Look Like - <fname>James</fname><lname>Mays</lname> Output Would Look Like - James Mays This is the part I'm struggling with, I don't know how to tell the php to not display the XML tags - NOT DONE If this helps here is what code I do have, HTML Page <!DOCTYPE HTML> <html> <head> </head> <body> <form action="test.php" method="post"> <p>Text Area:</p> <textarea name="xmltags" rows="10" cols="40"></textarea></p> <p><input type="submit" value="Submit"></p> </form> </div> </div> </body> </html> PHP Code <html> <body> Text Output: <?php echo $_POST["xmltags"]; ?>!<br /> </body> </html> Thank You for any and all help
  18. Its all working now except the calculation of the totaling of the accumulated score. I'm not sure if I was suppose to pas $score through something specific or what, But thank you very much for the help you have provided and I will look for better learning resources.
  19. Thank you I'll try and see if i can get that to work. I have just been trying to learn from online tutorials.
  20. Hi I am still learning PHP and have a project due. I haven't had any PHP classes so I am struggling with this project. It is suppose to be a text only output pinball simulation. It calculates the players skill level randomly, there are 4 bumpers and for banks, it calculates how many times each bumper and bank is hit and calculates the score outputting all info in text no formatting. My code looks like it should work but doesn't output correctly and I can't figure out way. Here is the output : Notice: Undefined variable: skillLevel in C:\xampp\htdocs\pinball.php on line 39 Notice: Undefined variable: skillLevel in C:\xampp\htdocs\pinball.php on line 39 Notice: Undefined variable: skillLevel in C:\xampp\htdocs\pinball.php on line 42 Notice: Undefined variable: skillLevel in C:\xampp\htdocs\pinball.php on line 42 Notice: Undefined variable: skillLevel in C:\xampp\htdocs\pinball.php on line 45 Notice: Undefined variable: skillLevel in C:\xampp\htdocs\pinball.php on line 45 Notice: Undefined variable: skillLevel in C:\xampp\htdocs\pinball.php on line 48 Notice: Undefined variable: skillLevel in C:\xampp\htdocs\pinball.php on line 48 Notice: Undefined variable: skillLevel in C:\xampp\htdocs\pinball.php on line 51 Notice: Undefined variable: skillLevel in C:\xampp\htdocs\pinball.php on line 51 Notice: Undefined variable: skillLevel in C:\xampp\htdocs\pinball.php on line 54 Notice: Undefined variable: skillLevel in C:\xampp\htdocs\pinball.php on line 54 Welcome To God Mode! Ball Launched! Notice: Undefined variable: skillLevel in C:\xampp\htdocs\pinball.php on line 64 Bumper 4 Hit. Bumper 2 Hit. Bank 2 Hit! Notice: Undefined variable: bank2 in C:\xampp\htdocs\pinball.php on line 441 Damn You Suck!!!! Notice: Undefined variable: bank1 in C:\xampp\htdocs\pinball.php on line 905 Notice: Undefined variable: bank1Pegs in C:\xampp\htdocs\pinball.php on line 907 Notice: Undefined variable: bank1 in C:\xampp\htdocs\pinball.php on line 905 Notice: Undefined variable: bank1 in C:\xampp\htdocs\pinball.php on line 905 Notice: Undefined variable: bank1 in C:\xampp\htdocs\pinball.php on line 905 Notice: Undefined variable: bank1 in C:\xampp\htdocs\pinball.php on line 905 Notice: Undefined variable: bank1 in C:\xampp\htdocs\pinball.php on line 905 Notice: Undefined variable: bank2 in C:\xampp\htdocs\pinball.php on line 913 Notice: Undefined variable: bank2Pegs in C:\xampp\htdocs\pinball.php on line 915 Notice: Undefined variable: bank2 in C:\xampp\htdocs\pinball.php on line 913 Notice: Undefined variable: bank2 in C:\xampp\htdocs\pinball.php on line 913 Notice: Undefined variable: bank2 in C:\xampp\htdocs\pinball.php on line 913 Notice: Undefined variable: bank2 in C:\xampp\htdocs\pinball.php on line 913 Notice: Undefined variable: bank2 in C:\xampp\htdocs\pinball.php on line 913 Notice: Undefined variable: bank3 in C:\xampp\htdocs\pinball.php on line 921 Notice: Undefined variable: bank3Pegs in C:\xampp\htdocs\pinball.php on line 923 Notice: Undefined variable: bank3 in C:\xampp\htdocs\pinball.php on line 921 Notice: Undefined variable: bank3 in C:\xampp\htdocs\pinball.php on line 921 Notice: Undefined variable: bank3 in C:\xampp\htdocs\pinball.php on line 921 Notice: Undefined variable: bank3 in C:\xampp\htdocs\pinball.php on line 921 Notice: Undefined variable: bank3 in C:\xampp\htdocs\pinball.php on line 921 Notice: Undefined variable: bank4 in C:\xampp\htdocs\pinball.php on line 929 Notice: Undefined variable: bank4Pegs in C:\xampp\htdocs\pinball.php on line 931 Notice: Undefined variable: bank4 in C:\xampp\htdocs\pinball.php on line 929 Notice: Undefined variable: bank4 in C:\xampp\htdocs\pinball.php on line 929 Notice: Undefined variable: bank4 in C:\xampp\htdocs\pinball.php on line 929 Notice: Undefined variable: bank4 in C:\xampp\htdocs\pinball.php on line 929 Notice: Undefined variable: bank4 in C:\xampp\htdocs\pinball.php on line 929 Notice: Undefined variable: score in C:\xampp\htdocs\pinball.php on line 946 Notice: Undefined variable: bumper1Hits in C:\xampp\htdocs\pinball.php on line 951 Notice: Undefined variable: bumper2Hits in C:\xampp\htdocs\pinball.php on line 952 Notice: Undefined variable: bumper3Hits in C:\xampp\htdocs\pinball.php on line 953 Notice: Undefined variable: bumper4Hits in C:\xampp\htdocs\pinball.php on line 955 GAME OVER! Your Score: Number Of Pegs Left In Bank 1: 6; Number Of Pegs Left In Bank 2: ; Number Of Pegs Left In Bank 3: 6; Number Of Pegs Left In Bank 4: 6; Number Bumper 1 Hit: Number Bumper 2 Hit: Number Bumper 3 Hit: Number Bumper 4 Hit: Refresh Page To Play Again! Here is the code: <?php $score; $bank1PegsNotHit; $bank2PegsNotHit; $bank3PegsNotHit; $bank4PegsNotHit; $bumper1Hits; $bumper2Hits; $bumper3Hits; $bumper4Hits; $skillLevel = 2 - (getRandom() * 0.01); $bank1[0] = true; $bank1[1] = true; $bank1[2] = true; $bank1[3] = true; $bank1[4] = true; $bank1[5] = true; $bank2[0] = true; $bank2[1] = true; $bank2[2] = true; $bank2[3] = true; $bank2[4] = true; $bank2[5] = true; $bank3[0] = true; $bank3[1] = true; $bank3[2] = true; $bank3[3] = true; $bank3[4] = true; $bank3[5] = true; function launch() { $player; switch ($skillLevel) { case $skillLevel < 1.1: $player = " First Timer"; break; case $skillLevel < 1.2: $player = " Beginer"; break; case $skillLevel < 1.3: $player = " Regular"; break; case $skillLevel < 1.4: $player = " Advanced"; break; case $skillLevel < 1.5: $player = " Pro"; break; case $skillLevel < 1.6: $player = " Olympic "; break; default: $player = " God "; break; } echo "Welcome To<strong>$player</strong>Mode!<br />Ball Launched!<br /><br />"; switch ($i = $skillLevel * getRandom()) { case $i <= 5: hole(); break; case $i <= 20: flipper(); break; case $i <= 25: bumper4(); break; case $i <= 30: bumper3(); break; case $i <= 65: bumper1(); break; default: bumper4(); break; } } function bumper1() { global $score; $score+= 100; global $bumper1Hits; $bumper1Hits += 1; echo "<br />Bumper 1 Hit."; switch ($i = getRandom()) { case $i <= 25: bumper2(); break; case $i <= 50: bumper3(); break; case $i <= 60: bumper4(); break; case $i <= 70: bank1(); break; case $i <= 75: bank2(); break; case $i <= 80: bank3(); break; case $i <= 95: flipper(); break; default: hole(); break; } } function bumper2() { global $score; $score+= 100; global $bumper1Hits; $bumper1Hits += 1; echo "<br />Bumper 2 Hit."; switch ($i = getRandom()) { case $i <= 25: bumper1(); break; case $i <= 35: bumper3(); break; case $i <= 60: bumper4(); break; case $i <= 65: bank1(); break; case $i <= 75: bank2(); break; case $i <= 80: bank4(); break; case $i <= 95: flipper(); break; default: hole(); break; } } function bumper3() { global $score; $score+= 500; global $bumper1Hits; $bumper1Hits += 1; echo "<br />Bumper 3 Hit."; switch ($i = getRandom()) { case $i <= 25: bumper1(); break; case $i <= 35: bumper2(); break; case $i <= 60: bumper4(); break; case $i <= 65: bank1(); break; case $i <= 90: bank3(); break; case $i <= 95: flipper(); break; default: hole(); break; } } function bumper4() { global $score; $score+= 500; global $bumper1Hits; $bumper1Hits += 1; echo "<br />Bumper 4 Hit."; switch ($i = getRandom()) { case $i <= 10: bumper1(); break; case $i <= 35: bumper2(); break; case $i <= 60: bumper3(); break; case $i <= 65: bank2(); break; case $i <= 90: bank4(); break; case $i <= 95: flipper(); break; default: hole(); break; } } function bank1() { echo "<br />Bank 1 Hit!"; switch ($i = getRandom()) { case $i <= 16: if ($bank1[0]) { global $score; $score+= 10; global $bank1; $bank1[0] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 32: if ($bank1[1]) { global $score; $score+= 10; global $bank1; $bank1[1] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 48: if ($bank1[2]) { global $score; $score+= 10; global $bank1; $bank1[2] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 64: if ($bank1[3]) { global $score; $score+= 10; global $bank1; $bank1[3] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 80: if ($bank1[4]) { global $score; $score+= 10; global $bank1; $bank1[4] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 96: if ($bank1[5]) { global $score; $score+= 10; global $bank1; $bank1[5] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 99; flipper(); break; default: hole(); break; } } function bank2() { echo "<br />Bank 2 Hit!"; switch ($i = getRandom()) { case $i <= 16: if ($bank2[0]) { global $score; $score+= 10; global $bank2; $bank2[0] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 32: if ($bank2[1]) { global $score; $score+= 10; global $bank2; $bank2[1] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 48: if ($bank2[2]) { global $score; $score+= 10; global $bank2; $bank2[2] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 64: if ($bank2[3]) { global $score; $score+= 10; global $bank2; $bank2[3] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 80: if ($bank2[4]) { global $score; $score+= 10; global $bank2; $bank2[4] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 96: if ($bank2[5]) { global $score; $score+= 10; global $bank2; $bank2[5] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 99; flipper(); break; default: hole(); break; } } function bank3() { echo "<br />Bank 3 Hit!"; switch ($i = getRandom()) { case $i <= 16: if ($bank3[0]) { global $score; $score+= 10; global $bank3; $bank3[0] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 32: if ($bank3[1]) { global $score; $score+= 10; global $bank3; $bank3[1] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 48: if ($bank3[2]) { global $score; $score+= 10; global $bank3; $bank3[2] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 64: if ($bank3[3]) { global $score; $score+= 10; global $bank3; $bank3[3] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 80: if ($bank3[4]) { global $score; $score+= 10; global $bank3; $bank3[4] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 96: if ($bank3[5]) { global $score; $score+= 10; global $bank3; $bank3[5] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 99; flipper(); break; default: hole(); break; } } function bank4() { echo "<br />Bank 4 Hit!"; switch ($i = getRandom()) { case $i <= 16: if ($bank4[0]) { global $score; $score+= 10; global $bank4; $bank4[0] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 32: if ($bank4[1]) { global $score; $score+= 10; global $bank4; $bank4[1] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 48: if ($bank4[2]) { global $score; $score+= 10; global $bank4; $bank4[2] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 64: if ($bank4[3]) { global $score; $score+= 10; global $bank4; $bank4[3] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 80: if ($bank4[4]) { global $score; $score+= 10; global $bank4; $bank4[4] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 96: if ($bank4[5]) { global $score; $score+= 10; global $bank4; $bank4[5] = false; } switch ($i = getRandom()) { case $i <= 40; bumper1(); break; case $i <= 80: bumper2(); break; case $i <= 95: flipper(); break; default: hole(); break; } break; case $i <= 99; flipper(); break; default: hole(); break; } } function flipper() { switch ($i = $skillLevel * getRandom()) { case $i <= 10: hole(); break; case $i <= 15: bank3(); break; case $i <= 20: bank4(); break; case $i <= 25: bank1(); break; case $i <= 30: bank2(); break; case $i <= 47: bumper1(); break; case $i <= 64: bumper2(); break; case $i <= 81: bumper3(); break; default: bumper4(); break; } } function hole() { echo "<br />Damn You Suck!!!!<br />"; $bank1Pegs; $bank2Pegs; $bank3Pegs; $bank4Pegs; for ($i = 0; $i <= 5; $i++) { if (!$bank1[$i]) { $bank1Pegs += 1; } } for ($i = 0; $i <= 5; $i++) { if (!$bank2[$i]) { $bank2Pegs += 1; } } for ($i = 0; $i <= 5; $i++) { if (!$bank3[$i]) { $bank3Pegs += 1; } } for ($i = 0; $i <= 5; $i++) { if (!$bank4[$i]) { $bank4Pegs += 1; } } global $bank1PegsNotHit; $bank1PegsNotHit = $bank1Pegs; global $bank2PegsNotHit; $bank1PegsNotHit = $bank2Pegs; global $bank3PegsNotHit; $bank3PegsNotHit = $bank3Pegs; global $bank4PegsNotHit; $bank4PegsNotHit = $bank4Pegs; echo <<< EOD <br /><h4>GAME OVER!</h4> Your Score: <strong>$score</strong> Number Of Pegs Left In Bank 1: <strong>$bank1PegsNotHit;</strong> Number Of Pegs Left In Bank 2: <strong>$bank2PegsNotHit;</strong> Number Of Pegs Left In Bank 3: <strong>$bank3PegsNotHit;</strong> Number Of Pegs Left In Bank 4: <strong>$bank4PegsNotHit;</strong> Number Bumper 1 Hit: <strong>$bumper1Hits</strong> Number Bumper 2 Hit: <strong>$bumper2Hits</strong> Number Bumper 3 Hit: <strong>$bumper3Hits</strong> Number Bumper 4 Hit: <strong>$bumper4Hits</strong> Refresh Page To Play Again! EOD; } function getRandom() { return rand(1, 100); } launch(); ?> Any help fixing it would be greatly appreciated. Thank You All
×
×
  • 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.