Jump to content

cmaclennan

Members
  • Posts

    74
  • Joined

  • Last visited

    Never

Contact Methods

  • MSN
    craigmaclennan@hotmail.com

Profile Information

  • Gender
    Male
  • Location
    Toronto, Canada

cmaclennan's Achievements

Member

Member (2/5)

0

Reputation

  1. Thanks, I knew I needed a fresh set of eyes. Much appreciated.
  2. Hi Guys, I'm hoping someone can find what I clearly cant see, I have a page meant to update database records, the page will load and populate with the existing data and allow 5 out of the 7 fields to be edited, however when editing any of those 5, the remaining 2 blank out and can't be filled in again. Im at a bit of loss and have been staring at it for a bit too long i think, hoping a fresh set of eyes can help. Here's the page (the fields I'm having issues with are inv1/inv2: <?php $page_title = 'Edit a Cart'; include ('style.html'); // Check for a valid ID, through GET or POST. if ( (isset($_GET['id'])) ) { // Accessed through active_search.php $id = $_GET['id']; } elseif ( (isset($_POST['id'])) ) { // Form has been submitted. $id = $_POST['id']; } else { // No valid ID, kill the script. echo '<div id="title">Page Error</div> <p class="error">This page has been accessed in error.</p><p><br /><br /></p>'; exit(); } require_once ('mysql_connect.php'); // Connect to the db. // Check if the form has been submitted. if (isset($_POST['submitted'])) { $errors = array(); // Initialize error array. // Check for a PO. { $po = trim($_POST['po']); } // Check for a Master Serial. { $sr = trim($_POST['serial']); } // Check for a Charger Serial. { $ch = trim($_POST['charger']); } // Check for a Battery Serial. { $bt1 = trim($_POST['battery1']); } // Check for a Battery Serial. { $bt2 = trim($_POST['battery2']); } // Check for a Inverter Serial. { $in1 = trim($_POST['inv1']); } // Check for a 2nd Inverter Serial. { $in2 = trim($_POST['inv2']); } // Check for a Radio Serial. { $abc = trim($_POST['abc']); } if (empty($errors)) { // If everything's OK. // Test for unique master serial. $query = "SELECT serial FROM serials WHERE serial='$id'"; $result = mysql_query($query); if (mysql_num_rows($result) == 1) { // Make the query. $query = "UPDATE serials SET po='$po', serial='$sr', charger='$ch', batt1='$bt1', batt2='$bt2', inv1='$in1', inv2='$in2', abc='$abc' WHERE serial='$id'"; $result = @mysql_query ($query); // Run the query. if (mysql_affected_rows() == 1) { // If it ran OK. // Print a message. echo '<div id="title">Success!</div> <p>The node has been edited.<a href="javascript:window.close();">Close</a></p><p><br /><br /></p>'; } else { // If it did not run OK. echo '<div id="title">System Error</div> <p class="error">The node could not be edited due to a system error. We apologize for any inconvenience.</p>'; // Public message. echo '<p>' . mysql_error() . '<br /><br />Query: ' . $query . '</p>'; // Debugging message. exit(); } } else { // Already registered. echo '<div id="title">Error!</div> <p class="error">The Serial has already been registered.</p>'; } } else { // Report the errors. echo '<div id="title">Error!</div> <p class="error">The following error(s) occurred:<br />'; foreach ($errors as $msg) { // Print each error. echo " - $msg<br />\n"; } echo '</p><p>Please try again.</p><p><br /></p>'; } // End of if (empty($errors)) IF. } // End of submit conditional. // Always show the form. // Retrieve the user's information. $query = "SELECT * FROM serials WHERE serial='$id'"; $result = @mysql_query ($query); // Run the query. if (mysql_num_rows($result) == 1) { // Valid ID, show the form. // Get the user's information. $row = mysql_fetch_array ($result); // Create the form. echo '<div id="title">Edit a Cart</div> <form action="serial_edit.php" method="post"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td>P.O #:</td><td><input type="text" name="po" size="15" maxlength="15" value="' . $row['po'] . '" /></td> </tr> <tr> <td>Cart Serial:</td><td><input type="text" name="serial" size="15" maxlength="30" value="' . $row['serial'] . '" /></td> </tr> <tr> <td>Charger:</td><td><input type="text" name="charger" size="20" maxlength="40" value="' . $row['charger'] . '" /> </td> </tr> <tr> <td>Battery 1:</td><td><input type="text" name="battery1" size="20" maxlength="40" value="' . $row['batt1'] . '" /> </td> </tr> <tr> <td>Battery 2:</td><td><input type="text" name="battery2" size="20" maxlength="40" value="' . $row['batt2'] . '" /> </td> </tr> <tr> <td>Inverter 1:</td><td><input type="text" name="inverter1" size="20" maxlength="40" value="' . $row['inv1'] . '" /> </td> </tr> <tr> <td>Inverter 2:</td><td><input type="text" name="inverter2" size="20" maxlength="40" value="' . $row['inv2'] . '" /> </td> </tr> <tr> <td>ABC:</td><td><input type="text" name="abc" size="20" maxlength="40" value="' . $row['abc'] . '" /> </td> </tr> <tr> <td><input type="submit" name="submit" value="Submit" /><input type="hidden" name="submitted" value="TRUE" /></td> <td><input type="hidden" name="id" value="' . $id . '" /></td></tr> </form>'; } else { // Not a valid ID. echo '<div id="title">Page Error</div> <p class="error">This page has been accessed in error.</p><p><br /><br /></p>'; } mysql_close(); // Close the database connection. ?>
  3. Thanks Guys, I got it figured out now thanks a lot.
  4. Hey All, hoping I just need another set of eyes, but I have a search form that once submitted is supposed to return the values from a MySQL database, but i am getting nothing showing and no errors of any kind. Any Help is appreciated. <?php # Script 8.6.2 - order_search_field.php include ('style.htm'); $page_title = 'Find Ticket'; // Page header. echo '<div id="title">Find Ticket</div>'; // Check if the form has been submitted. if (isset($_GET['submitted'])) { $se = $_REQUEST['search'] ; // Register the user in the database. require_once ('mysql_connect.php'); // Connect to the db. // Make the query. $query = "SELECT * FROM tickets WHERE ticket_id LIKE '$se' OR company LIKE '$se'"; $result = @mysql_query ($query); // Run the query. if ($result) { // If it ran OK. // Print a message. echo '<br>Your entry has been found.</br><br/>'; while ($row = mysql_fetch_array($result)){ echo '<table width="650px" border="0" cellspacing="5" cellpadding="0"> <tr> <td colspan="4"><img src="images/powerlogo.gif" width="300" height="39" alt="PowerCart" /></td> </tr> <tr> <td colspan="4"></td> </tr> <tr> <td colspan="2"><strong>Ticket Details</strong></td> <td>Ticket Id: </td> <td>'; echo $row['ticket_id']; echo '</td> </tr> <tr> <td>Opened By:</td> <td>'; echo $row['name']; echo '</td> <td>Date:</td> <td>'; echo $row['date']; echo '</td> </tr> <tr> <td>Email:</td> <td>'; echo $row['email']; echo '</td> <td> </td> <td> </td> </tr> <tr> <td>Contact:</td> <td>'; echo $row['contact']; echo '</td> <td>Contact Email:</td> <td>'; echo $row['c_email']; echo '</td> </tr> <tr> <td>Phone:</td> <td>'; echo $row['phone']; echo '</td> <td>Ext:</td> <td>'; echo $row['ext']; echo '</td> </tr> <tr> <td>Store ID:</td> <td>'; echo $row['store_id']; echo '</td> <td> </td> <td> </td> </tr> <tr> <td>Address:</td> <td colspan="3">'; echo $row['address']; echo '</td> </tr> <tr> <td colspan="4"> </td> </tr> <tr> <td>Ticket Status:</td> <td>'; echo $row['status']; echo '</td> <td> </td> <td> </td> </tr> <tr> <td>Priority:</td> <td>'; echo $row['priority']; echo '</td> <td>Under Warranty:</td> <td>'; echo $row['warranty']; echo '</td> </tr> <tr> <td>Cart Serial:</td> <td>'; echo $row['serial']; echo '</td> <td>Original ship Date:</td> <td>'; echo $row['o_date']; echo '</td> </tr> <tr> <td>Issue:</td> <td>'; echo $row['issue']; echo '</td> <td>Technician Sent:</td> <td>'; echo $row['tech']; echo '</td> </tr> <tr> <td colspan="4"> </td> </tr> <tr> <td>Notes/Details:</td> <td colspan="3">'; echo $row['notes']; echo '</td> </tr> </table>'; } // Include the footer and quit the script (to not show the form). exit(); } else { // If it did not run OK. echo '<h1 id="mainhead">System Error</h1> <p class="error">Your entry could not be found due to a system error. We apologize for any inconvenience. Please advise the System Administrator</p>'; // Public message. echo '<p>' . mysql_error() . '<br /><br />Query: ' . $query . '</p>'; // Debugging message. exit(); } mysql_close(); // Close the database connection. } ?>
  5. Morning/Afternoon All. I have a dilema and a very short amount of time at this point and I'm looking for some help on deciding where would be best to begin or which is the best way to approach the problem. The company I work for needs an order entry form, it has to capture into a MySQL database the following, Customer Details, Shipping Details and all associated order details which in itself isnt the worst part as it also has to be able to capture each individual part ordered as each part has it's own unique serial number which they want to be able to have as well. Any help, suggestions etc are greatly appreciated and the sooner the better, I may even consider paying for something out there already if it has whats needed. Thanks in advance.
  6. Hi All, I have a question and im really not sure where at all to begin. What I would like to achieve is a basic page that can have a list of stores on it and next to the store either a green, yellow or red icon to show it's status. It sounds fairly simple and i could very well just be going through a bad case of brain freeze but any insight and help on getting this done would be appreciated. Thanks in Advance.
  7. Are you able to give me an example or somewhere I can find out how to use the function? Thanks
  8. Hi Guys, Hoping someone can assist me with this as im still a noob and not sure where to begin. I have a form that submits to a database and what I would like it to do is once submitted it stores the info in the database and sends a copy of what was submitted to a specific email or group of emails. Can someone help me out? Many Thanks.. Using PHP 5 and MySQL 5 on a WAMP server.
  9. <script language="javascript"> //add a row to the rows collection and get a reference to the newly added row var partsRowCount = 1; //stores the number of rows //add a new row to the table function addRow() { var namePrefix = "_" + (+partsRowCount + 1); //setup the prefix variable partsRowCount++; //increment the counter //add a row to the rows collection and get a reference to the newly added row var newRow = document.all("orderentry").insertRow(); //add 3 cells (<td>) to the new row and set the innerHTML to contain text boxes var oCell = newRow.insertCell(); oCell.innerHTML = "<input type='text' name='partid" + namePrefix + "'>"; oCell = newRow.insertCell(); oCell.innerHTML = "<input type='text' name='quantity" + namePrefix + "'>"; oCell = newRow.insertCell(); oCell.innerHTML = "<input type='text' name='desc" + namePrefix + "'>"; oCell = newRow.insertCell(); oCell.innerHTML = "<input type='text' name='serial" + namePrefix + "'>"; } //deletes the specified row from the table function removeRow(src) { /* src refers to the input button that was clicked. to get a reference to the containing <tr> element, get the parent of the parent (in this case case <tr>) */ var oRow = src.parentElement.parentElement; //once the row reference is obtained, delete it passing in its rowIndex document.all("orderentry").deleteRow(oRow.rowIndex); } </script>
  10. Hi Guys, I'm desperate for some help at this point, I have a php form that submits to a database and a portion of this form is to caputer serial numbers however the way i currently have it will add as many rows/fields as i need but only submits upto the first 9 for some reason and i really need some help with either figuring out why or coming up with an alternate solution. Any help would be hugely appreciated. Thanks
  11. Hey Guys, I have a script that allows for additional rows to be added to a form i have if needed but i have just noticed that when i get upto and above 10 rows it stops working and just submits the first 9 rows again. Any help is greatly appreciated as i need to get this fixed as soon as humanly possible. <script language="javascript"> //add a row to the rows collection and get a reference to the newly added row var partsRowCount = 1; //stores the number of rows //add a new row to the table function addRow() { var namePrefix = "_" + (+partsRowCount + 1); //setup the prefix variable partsRowCount++; //increment the counter //add a row to the rows collection and get a reference to the newly added row var newRow = document.all("orderentry").insertRow(); //add 3 cells (<td>) to the new row and set the innerHTML to contain text boxes var oCell = newRow.insertCell(); oCell.innerHTML = "<input type='text' name='partid" + namePrefix + "'>"; oCell = newRow.insertCell(); oCell.innerHTML = "<input type='text' name='quantity" + namePrefix + "'>"; oCell = newRow.insertCell(); oCell.innerHTML = "<input type='text' name='desc" + namePrefix + "'>"; oCell = newRow.insertCell(); oCell.innerHTML = "<input type='text' name='serial" + namePrefix + "'>"; } //deletes the specified row from the table function removeRow(src) { /* src refers to the input button that was clicked. to get a reference to the containing <tr> element, get the parent of the parent (in this case case <tr>) */ var oRow = src.parentElement.parentElement; //once the row reference is obtained, delete it passing in its rowIndex document.all("orderentry").deleteRow(oRow.rowIndex); } </script>
  12. Hi guys, Im sure ive done or missed something simple but my brain is in a bit of overload at the moment and I cant seem to see what i've done wrong, I have a query below that searches for a record and returns it when found however it displays the same message of entry found even when no record is returned and i cant seem to get a different message to appear i just get parse errors. Any help would be greatly appreciated. require_once ('mysql_connect2.php'); // Connect to the db. // Make the query. $query = "SELECT * FROM powercarts WHERE cart_serial LIKE '$se' or charger LIKE '$se' or inverter LIKE '$se' or battery LIKE '$se' or battery2 LIKE '$se' or inverter2 LIKE '$se' or po LIKE '$se'"; $result = @mysql_query ($query); // Run the query. if (mysql_num_rows($result) == 1) { // If it ran OK. // Print a message. echo '<br>Your entry has been found.</br><br/>'; while ($row = mysql_fetch_array($result)){ echo 'PO: '.$row['po']; echo '<br/> Date: '.$row['date']; echo '<br/> Cart Serial: '.$row['cart_serial']; echo '<br/> Charger: '.$row['charger']; echo '<br/> Battery: '.$row['battery']; echo '<br/> 2nd Battery: '.$row['battery2']; echo '<br/> Inverter: '.$row['inverter']; echo '<br/> 2nd Inverter: '.$row['inverter2']; echo '<br/><a href="powercart_edit.php?id=' . $row['cart_serial'] . '" target="_blank">Edit</a> <a href="order_view_carts.php?id=' . $row['po'] . '" target="_blank">View</a>'; echo '<br/><br/>'; } else { // Not a valid Customer ID. echo '<div id="title">Page Error</div> <p class="error">This page has been accessed in error.</p><p><br /><br /></p>'; } exit(); } mysql_close(); // Close the database connection.
  13. Hey Guys, hoping someone can tell me what i'm missing or where im going wrong with my code im trying to return data from multiple tables into an excel sheet, here is the code I have so far that I have found online and tweaked a little but all I get in the file is the last colum header and number. Thanks in advance. <?php include('mysql_connect.php'); $result = mysql_query('SELECT customers_log.*, shipping.*, orders.*, parts_ordered.* FROM customers_log, shipping, orders, parts_ordered WHERE customers_log.customer_id = shipping.customer_id AND shipping.shipping_id = orders.shipping_id AND orders.order_id = parts_ordered.order_id '); $count = mysql_num_fields($result); for ($i = 0; $i < $count; $i++){ $header = mysql_field_name($result, $i)."\t"; } while($row = mysql_fetch_row($result)){ $line = ''; foreach($row as $value){ if(!isset($value) || $value == ""){ $value = "\t"; }else{ # important to escape any quotes to preserve them in the data. $value = str_replace('"', '""', $value); # needed to encapsulate data in quotes because some data might be multi line. # the good news is that numbers remain numbers in Excel even though quoted. $value = '"' . $value . '"' . "\t"; } $line = $value; } $data = trim($line)."\n"; } # this line is needed because returns embedded in the data have "\r" # and this looks like a "box character" in Excel $data = str_replace("\r", "", $data); # Nice to let someone know that the search came up empty. # Otherwise only the column name headers will be output to Excel. if ($data == "") { $data = "\nno matching records found\n"; } # This line will stream the file to the user rather than spray it across the screen header("Content-Type: application/vnd.ms-excel; name='excel'"); header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=orderlog.xls"); header("Pragma: no-cache"); header("Expires: 0"); echo $header."\n".$data; //print "done"; ?>
  14. Hey guys, Hoping someone can help me out here, I have a query thats pulling essentially an order record from multiple tables, it pulls all of the customer details etc as it should however when the order contains more than 1 part for example instead of just returning 1 set of order details and repeating the parts it repeats all of the information for each part. When i noticed this i split the parts query off from the main one and it groups the parts together but still shows 2 sets of customer details. Hope someone can point me in the right direction i could use a fresh set of eyes. // Check for a valid part ID, through GET or POST. if ( (isset($_GET['id'])) ) { // Accessed through parts_search.php $id = $_GET['id']; } elseif ( (isset($_POST['id'])) ) { // Form has been submitted. $id = $_POST['id']; } else { // No valid ID, kill the script. echo '<div id="title">Page Error</div> <p class="error">This page has been accessed in error.</p><p><br /><br /></p>'; exit(); } require_once ('mysql_connect.php'); // Connect to the db. //Make the Query $result = mysql_query("SELECT customers_log.*, shipping.*, orders.*, parts_ordered.* FROM customers_log, shipping, orders, parts_ordered WHERE customers_log.customer_id = shipping.customer_id AND shipping.shipping_id = orders.shipping_id AND orders.order_id = parts_ordered.order_id AND parts_ordered.order_id='$id'"); while($row = mysql_fetch_array($result)) //Print Data { echo '<table width="700" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="7" bgcolor="#FFFFFF"><img src="images/powerlogo.gif" width="300" height="39" alt="PowerCart" /></td> </tr> <tr> <td colspan="4"><strong>Customer Details</strong></td> ... <tr> <td>Tracking #:</td> <td colspan="2">'; echo $row['tracking']; echo '</td> <td></td> <td colspan="3"></td> </tr> <tr> <td colspan="7"> </td> </tr> </table><p>'; } // Make the query. $query = "SELECT * FROM parts_ordered WHERE order_id='$id'"; $result = @mysql_query ($query); // Run the query. // Table header. echo '<table cellspacing="5" cellpadding="0" width="650px"> <tr> <td align="left"><b>Item</b></td> <td align="left"><b>Description</b></td> <td align="left"><b>Quantity</b></td> <td align="left"><b>Serial</b></td> </tr> '; // Fetch and print all the records. $bg = '#eeeeee'; // Set the background color. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch the background color. echo '<tr bgcolor="' . $bg . '"> <td align="left">' . $row['partid'] . '</td> <td align="left">' . $row['desc'] . '</td> <td align="left">' . $row['quantity'] . '</td> <td align="left">' . $row['serial'] . '</td> </tr> '; } echo '</table>';
×
×
  • 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.