Jump to content

Angelojoseph17

Members
  • Posts

    44
  • Joined

  • Last visited

Everything posted by Angelojoseph17

  1. I have the folllowing loop which only displays the last part of the array: $i = 0; // create a varible that will tell us how many items we looped over foreach ($listprint as $key => $value) { $i++; $content2 = " <tr> <th>Qty</th> <th>Description</th> <th>ProductNumber</th> <th>Issue</th> </tr> <tr > <td>" . $value['Quantity'] . "</td></a> <td>" . $value['Description'] . "</td></a> <td>" . $value['ProductNumber'] . "</td></a> <td>" . $value['Issue'] . "</td></a> </tr> </table> "; } The array Array ( [0] => Array ( [ReferenceNumber] => 4543/2323/ [CustomerNumber] => CHU15 [CustomerName] => AngeloJoseph [Description] => Tewksbury [ProductNumber] => 2323/3232 [Quantity] => 5 [issue] => Holes in lining ) [1] => Array ( [ReferenceNumber] => 4543/2323/ [CustomerNumber] => CHU15 [CustomerName] => AngeloJoseph [Description] => Ryder Sahara Boots [ProductNumber] => 34343/232 [Quantity] => 2 [issue] => Ripped Lining ) [2] => Array ( [ReferenceNumber] => 4543/2323/ [CustomerNumber] => CHU15 [CustomerName] => AngeloJoseph [Description] => Oxford Brogues [ProductNumber] => 23232/323 [Quantity] => 1 [issue] => Broken Last ) )
  2. public function ListProduct($Order) { $sql = "SELECT `Order`.`OrderNumber` , `Despatch`.`OrderNumber` , `Stock`.`ProductCode` , `Stock`.`Description` , `Stock`.`ProductGroup` , `Stock`.`Size` , `Stock`.`IPICODE` FROM `Stock` , `Despatch` ,`Order` WHERE `Order`.`OrderNumber` = '" . $Order. "' AND`Order`.`OrderNumber` = `Despatch`.`OrderNumber` AND`Despatch`.`Product`= `Stock`.`ProductCode` "; // echo $sql; mysql_select_db(DB_DATABASE_NAME, $this->conn); $result = mysql_query($sql, $this->conn); //$num_rows = mysql_num_rows($result); //echo "Number of rows : $num_rows"; while($row = mysql_fetch_array($result)) { if($row[0] != "") { $result = mysql_query($sql, $this->conn); $num_rows = mysql_num_rows($result); //echo "Number of rows : $num_rows"; } else { $sql = "SELECT `Order`.`OrderNumber` , `Despatch`.`OrderNumber` , `Stock`.`ProductCode` , `Stock`.`Description` , `Stock`.`ProductGroup` , `Stock`.`Size` , `Stock`.`IPICODE` FROM `Stock` , `Despatch` ,`Order` WHERE `Order`.`OrderNumber` = '" . $Order. "' AND`Order`.`ProductCode`= `Stock`.`ProductCode` "; mysql_select_db(DB_DATABASE_NAME, $this->conn); $result = mysql_query($sql, $this->conn); $num_rows = mysql_num_rows($result); //echo "Number of rows : $num_rows"; while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $return[] = $row; } return $return; return $num_rows; } } I have the query above which check if any rows are returned from the first sql statement and if the rows are empty, the aim is to run the second query and returns results. However i am going wrong somewhere. Can someone have a look. Perhaps i am over complicating this?
  3. I have a drop down box with two options depending on the option chosen it will open up another text box or a drop down box. Below is my function in ajax and also the php code. It partially works. But when i choose the value byreturn it shows both. Also on load it shows both which is annoying. I would appreciate it if anyone has a look. Thank you: Ajax function showfield(name){ if(name=='byreturn')document.getElementById('div1').style.display="block"; else document.getElementById('div1').style.display="none"; if(name=='forwardorder')document.getElementById('div2').style.display="block"; else document.getElementById('div2').style.display="none"; } Php on the page $content .=" <tr><td> Choose Delivery Type </td> <td> <select name = 'elementtype1'id='elementtype1' onchange='showfield(this.options[this.selectedIndex].value)'> <option value='forwardorder'>Forward Order</option> <option value='byreturn'>By Return</option> </select></td> <td> <div id='div1'>Enter By Return Date<input type='text''name='whatever1' /> </div> <div id='div2'> <td> Forward Order Delivery </td> <td><select 'name'='whatever2'/>"; $listCapacityDates = $cid->ListCapacity(); //echo $listCapacityDates; foreach($listCapacityDates as $x) { $content .= "<option value='".$x."'>".$x."</option> </div>"; }
  4. I fixed it, dont worry. I add an entry on the css sheet and i also changed my if statement. if(strtotime($x['DueDate']) < strtotime($todays_date)){ $content .= "<tr class='highlight'> <td>" . $x['Description'] . "</td> <td>" . $x['WorksOrder'] . "</td> <td>" . $x['Number'] . "</td> <td>" . $x['Reference'] . "</td> <td>" . $x['DueDate'] . "</td> <td>" . $x['Stock'] . "</td> </tr>"; } else { $content .= "<tr> <td>" . $x['Description'] . "</td> <td>" . $x['WorksOrder'] . "</td> <td>" . $x['Number'] . "</td> <td>" . $x['Reference'] . "</td> <td>" . $x['DueDate'] . "</td> <td>" . $x['Stock'] . "</td> </tr>"; }
  5. I have a php script which returns rows from a table. I match one of the dates in the table againsts todays date. If older than today the aim is to highlight the row. But some reason this is not working. I have tested my if statement with an echo which returns the right field. Can anyone spot the mistake? <?php // First of all initialise the user and check for permissions require_once "/var/www/users/user.php"; $user = new CHUser(7); // Initialise the template require_once "/var/www/template/template.php"; $template = new CHTemplate(); // And create a cid object require_once "/var/www/WIPProgress/DisplayWIPOnLocation.php"; $WIPProgress= new CHWIPProgress(); $content = "<h1>Check WIP Status on Location </h1>"; $content = "<form action='index.php' method='get' name ='location'> <select id='location' name ='location' > <option>Skin Room</option> <option>Clicking</option> <option>Kettering</option> <option>Closing</option> <option>Rushden</option> <option>Assembly</option> <option>Lasting</option> <option>Making</option> <option>Finishing</option> <option>Shoe Room</option> </select> <input type='submit' /> </form>"; if(isset($_GET['location'])) { $wip = $WIPProgress->ListWIPOnLocation($_GET['location']); $location = $_GET['location']; $todays_date = date("Y-m-d H:i:s"); // Now show the details $content .= "<h2>Details for $location </h2> <table> <tr> <th>PPDescription</th> <th>Works Order</th> <th>Bundle Number</th> <th>Bundle Reference</th> <th>Due Date</th> </tr>"; foreach($wip as $x) { if(strtotime($x['DueDate']) > strtotime($todays_date)){ $content .= "<tr background-color: #CC9999;> <td>" . $x['Description'] . "</td> <td>" . $x['WorksOrder'] . "</td> <td>" . $x['Number'] . "</td> <td>" . $x['Reference'] . "</td> <td>" . $x['DueDate'] . "</td> </tr>"; } } } else { $content .= "<h3>Please choose a location to view WIP</h3>"; } $template->SetTag("content", $content); echo $template->Display(); ?>
  6. Hi I have a query where it returns a few fields based on the location. I created a class for the function and an index page. It does not return any values. Can someone please advise/ THE CLASS <?php /**************************************** * * WIP Progress Class * * ****************************************/ class CHWIPProgress { var $conn; // Constructor, connect to the database public function __construct() { require_once "/var/www/reporting/settings.php"; define("DAY", 86400); if(!$this->conn = mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD)) die(mysql_error()); if(!mysql_select_db(DB_DATABASE_NAME, $this->conn)) die(mysql_error()); } public function ListWIPOnLocation($location) { $sql = "SELECT `ProgressPoint.PPDescription` AS Description ,`Bundle.WorksOrder` AS WorksOrder, `Bundle.BundleNumber` AS Number, `Bundle.BundleReference` AS Reference,`TWOrder.DueDate` AS Duedate FROM `TWOrder`,`Bundle`,`ProgressPoint` WHERE `Bundle.CurrentProgressPoint`=`ProgressPoint.PPNumber` AND `TWOrder.Colour=Bundle.Colour` AND `TWOrder.Size=Bundle.Size` AND `TWOrder.WorksOrderNumber`=`Bundle.WorksOrder` AND `ProgressPoint.PPDescription` LIKE '" . $location . "%' ORDER BY TWOrder.DueDate DESC"; mysql_select_db(DB_DATABASE_NAME, $this->conn); $result = mysql_query($sql, $this->conn); echo $sql; while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $return[] = $row; } return $return; } } ?> The index page <?php // First of all initialise the user and check for permissions require_once "/var/www/users/user.php"; $user = new CHUser(7); // Initialise the template require_once "/var/www/template/template.php"; $template = new CHTemplate(); // And create a cid object require_once "/var/www/WIPProgress/DisplayWIPOnLocation.php"; $WIPProgress= new CHWIPProgress(); $content = "Check WIP Status on Location <br>"; $content = "<form action='index.php' method='get' name ='location'> <select id='location' > <option>Skin Room</option> <option>Clicking</option> <option>Kettering</option> <option>Closing</option> <option>Rushden</option> <option>Assembly</option> <option>Lasting</option> <option>Making</option> <option>Finishing</option> <option>Shoe Room</option> </select> <input type='submit' /> </form>"; $wip = $WIPProgress->ListWIPOnLocation($_GET['location']); // Now show the details $content .= "<h2>Detail</h2> <table> <tr> <th>PPDescription</th> <th>Works Order</th> <th>Bundle Number</th> <th>Bundle Reference</th> <th>Due Date</th> </tr>"; foreach($wip as $x) { $content .= "<tr> <td>" . $x['Description'] . "</td> <td>" . $x['WorksOrder'] . "</td> <td>" . $x['Number'] . "</td> <td>" . $x['Reference'] . "</td> <td>" . $x['DueDate'] . "</td> </tr>"; } $template->SetTag("content", $content); echo $template->Display(); ?> thank you
  7. class name is CHCID . its coming from the top of the create order page where i've initialised the class. require_once $CID_INCLUDE_PATH . "/cid.php"; $cid = new CHCID();
  8. PHP Fatal error: Call to undefined method CHCID::UpdateDeliveryAddress()
  9. I have a class called cid which contains these functions: public function UpdateDeliveryAddress($orderNumber, $deliveryaddress) { $sql = "UPDATE `CIDOrders` SET `DeliveryAddress` = '" . mysql_real_escape_string($deliveryaddress) . "' WHERE `CIDOrderNumber` = " . $orderNumber . ";"; mysql_select_db(DB_DATABASE_NAME, $this->conn); return mysql_query($sql, $this->conn); } public function UpdateInvoiceAddress($orderNumber, $invoiceAddress) { $sql = "UPDATE `CIDOrders` SET `InvoiceAddress` = '" . mysql_real_escape_string($invoiceaddress) . "' WHERE `CIDOrderNumber` = " . $orderNumber . ";"; mysql_select_db(DB_DATABASE_NAME, $this->conn); return mysql_query($sql, $this->conn); } It is called in a page called create order. / Add a new delivery address to the order $cid->UpdateDeliveryAddress($_POST['orderNumber'], $_POST['deliveryaddress']); // Add invoice address to the order $cid->UpdateInvoiceAddress($_POST['orderNumber'], $_POST['invoiceaddress']); I get a call to undefined method error. Can anyone help me. thank you
  10. This server is on a virtual machine. I increased the memory and the script ran. I will let it run on crontab tommorow and tell you how it goes. Many thanks Angelo
  11. Just had a look at the logs all seem normal or dont tell much apart from the syslog. This is the error message on there at the time where crontab is meant to run this script: Sep 27 09:50:48 IT kernel: [1726073.814062] php invoked oom-killer: gfp_mask=0x201da, order=0, oom_adj=0 Sep 27 09:50:48 IT kernel: [1726073.814137] php cpuset=/ mems_allowed=0 Sep 27 09:50:48 IT kernel: [1726073.814160] Pid: 979, comm: php Not tainted 2.6.32-30-generic #59-Ubuntu Sep 27 09:50:48 IT kernel: [1726073.814182] Call Trace: Sep 27 09:50:48 IT kernel: [1726073.814291] [<c01ce494>] oom_kill_process+0xa4/0x2b0 Sep 27 09:50:48 IT kernel: [1726073.814304] [<c01ceb09>] ? select_bad_process+0xa9/0xe0 Sep 27 09:50:48 IT kernel: [1726073.814310] [<c01ceb91>] __out_of_memory+0x51/0xa0 Sep 27 09:50:48 IT kernel: [1726073.814316] [<c01cec38>] out_of_memory+0x58/0xb0 Sep 27 09:50:48 IT kernel: [1726073.814322] [<c01d1517>] __alloc_pages_slowpath+0x487/0x4a0 Sep 27 09:50:48 IT kernel: [1726073.814329] [<c01d166a>] __alloc_pages_nodemask+0x13a/0x170 Sep 27 09:50:48 IT kernel: [1726073.814336] [<c01d3c2a>] __do_page_cache_readahead+0xea/0x200 Sep 27 09:50:48 IT kernel: [1726073.814342] [<c01d3d66>] ra_submit+0x26/0x30 Sep 27 09:50:48 IT kernel: [1726073.814348] [<c01ccf0c>] filemap_fault+0x3dc/0x410 Sep 27 09:50:48 IT kernel: [1726073.814373] [<c01e6440>] __do_fault+0x40/0x490 Sep 27 09:50:48 IT kernel: [1726073.814380] [<c01d4a51>] ? lru_cache_add_lru+0x21/0x40 Sep 27 09:50:48 IT kernel: [1726073.814387] [<c01ef024>] ? page_add_new_anon_rmap+0x64/0x70 Sep 27 09:50:48 IT kernel: [1726073.814393] [<c01e80a9>] handle_mm_fault+0x139/0x390 Sep 27 09:50:48 IT kernel: [1726073.814471] [<c05918cd>] do_page_fault+0x10d/0x3a0 Sep 27 09:50:48 IT kernel: [1726073.814496] [<c05917c0>] ? do_page_fault+0x0/0x3a0 Sep 27 09:50:48 IT kernel: [1726073.814502] [<c058f7c3>] error_code+0x73/0x80 Sep 27 09:50:48 IT kernel: [1726073.814513] Mem-Info: I will increase the ulimit of my user account its currently at 1024.
  12. thanks i will have a look at the logs.
  13. The attachment is a oracle query converted into excel which i suspect is the issue as the file gets as big as 13 mb.
  14. Hi, I have a php script that is meant to run daily which queries an oracle database and stores results in a csv file before emailing it to certain users. However when run on crontab or even manually the script is killed by the system. Has anyone got any suggestions on where i would need to look to check for error logs. Emails are sent using the mail php class. Also the data attached in the email is usually around 12mb. Many thanks.
  15. have you got any example scripts knocking around? many thanks
  16. Hi Guys. I need your help. Is it possible to store results from sql query as a variable. I am basically doing a few joins to get this result and I wanted to know if this was possible.
  17. Hi i need a bit of help. i have toner database which stores, the type, brand, colour, min, max stock. I just want to know if there is anyway of notifying the user when the toner reachs the min level, maybe highligh the row in red or something similar. many thanks.
  18. $pdf->Table('select * from repairs where machine_number = '.$q.''); Thanks guys I got it to work in the end.
  19. it will pull out the results from the database and insert it into the pdf. lol sorry bit of dumb moment there.
  20. I'm trying to create a pdf from a form where the user selects a machine_id and that pulls out a pdf based on the variable being passed. I'm pretty sure it is the query where i am doing something wrong. Can someone help. Much appreciated. <?php require('mysql_table.php'); $q=$_GET["q"]; class PDF extends PDF_MySQL_Table { function Header() { //Title $this->SetFont('Arial','',18); $this->Cell(0,6,'Machine Details',0,1,'C'); $this->Ln(10); //Ensure table header is output parent::Header(); } } //Connect to database mysql_connect('localhost','bla','bla'); mysql_select_db('bla'); $pdf=new PDF(); $pdf->AddPage(); //First table: put all columns automatically $this->Cell(0,6,'Repair History',0,1,'C'); $pdf->Table('SELECT * FROM repairs WHERE machine_number = $q'); $pdf->Output(); ?>
  21. thanks , thats a great little add on. Wrote a pdf with mysql output within 5 mins and I think of myself as a beginner. Great stuff thank you
  22. I need some advice. I want to know if there is some third party app or script i can adapt which runs multiple querys and outputs them to pdf. So for example i had a table called machines and I wanted query an output the most used machines into a report is there any way to doing so. The end user of this will have no experience in php so ideally i want to encorporate the report as a button or something similar. Thank you
  23. | Field | Type | Null | Key | Default | Extra | +-------------------+--------------+------+-----+---------------------+--------- -------+ | repair_id | mediumint(9) | NO | PRI | NULL | auto_inc rement | | machine_number | varchar(100) | YES | MUL | NULL | | | reported_by | varchar(100) | YES | | NULL | | | repair_start_date | datetime | NO | | 0000-00-00 00:00:00 | | | repair_end_date | datetime | NO | | 0000-00-00 00:00:00 | | | fault_description | varchar(100) | YES | | NULL | | | repaired_by | varchar(100) | YES | MUL | NULL | | | part_used | mediumint(9) | YES | MUL | NULL |
  24. <html> <div id = "form" align="center"> <h1> Create a repair Ticket </h1> <?php // Connects to Database mysql_connect("localhost", "angelo", "password") or die(mysql_error()); mysql_select_db("church_engineers") or die(mysql_error()); ?> <form action="insert.php" method="post"> <p> Choose the machine to be repaired: </p> <select name ="machine_id"> <?php // This query selects the machine_id and name from the machine table and stores in the "result" variable. $sql="SELECT machine_id,description FROM machine"; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ ?> <option value="<?PHP echo $data['machine_id']; ?>"><?PHP echo $data['description']; ?></option><br> <?php } ?> </select> <p> Choose the engineer to be allocated: </p> <select name ="engineer_name"> <?php // This query selects engineer_id and name $sql="SELECT engineer_id,engineer_name FROM engineer"; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ ?> <option value="<?PHP echo $data['engineer_id']; ?>"><?PHP echo $data['engineer_name']; ?></option><br> <?PHP } ?> </select> <p> Choose the part to be allocated: </p> <select name ="part_number"> <?php // This query selects engineer_id and name $sql="SELECT part_number,description FROM parts"; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ ?> <option value="<?PHP echo $data['description']; ?>"><?PHP echo $data['part_number']; ?></option><br> <?PHP } ?> </select> <p> Reported By: <input type="text" name="reported_by" /> </p> <p><b>Fault Description</b> </p> <textarea cols="50" rows="4" name="fault_description" align="right" wrap="virtual"></textarea> <br> <input type="Submit"> </form> <?php ini_set("display_errors", "1"); error_reporting(E_ALL); $con = mysql_connect("localhost","angelo","password"); if (!$con){ die('Could not connect: ' . mysql_error()); } mysql_select_db("church_engineers", $con); $machine_id= $_POST['machine_id']; $reportedby= $_POST['reported_by']; $Date = date("d/m/y"); $fault_description =$_POST['fault_description']; $repaired_by = $_POST['engineer_name']; $part_used = $_POST['part_number']; $sql="INSERT INTO repairs (machine_number, reported_by, repair_start_date, fault description, repaired_by, part_used) VALUES ('$machine_id', '$reportedby', '$Date', '$fault_description' , '$repaired_by', '$part_used')"; $result = mysql_query($sql); mysql_close($con); echo "You records have been updated"; ?>
  25. thanks for that lightbear what is wierd is that it creates a new record on the database with empty fields when i press submit and it churns this error message out now. Notice: Undefined index: part_number in /var/www/engineering/insert.php on line 16 You records have been updated
×
×
  • 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.