honkmaster
Members-
Posts
49 -
Joined
-
Last visited
Everything posted by honkmaster
-
Thank you so much, removed and it worked perfect. Thanks
-
Thanks, yes we are going update soon Below is the code but no fetch() mysql_select_db($database_workflow, $workflow); $query_rsB2Indigo = "SELECT * FROM stock_material WHERE stock_material.material_catagory = 'B2 Indigo' AND stock_material.material_status = 'Active'"; $rsB2Indigo = mysql_query($query_rsB2Indigo, $workflow) or die(mysql_error()); $row_rsB2Indigo = mysql_fetch_assoc($rsB2Indigo); $totalRows_rsB2Indigo = mysql_num_rows($rsB2Indigo); ob_end_clean(); $pdf = new TCPDF(); // add a page $resolution= array(210, 297); // set margins $pdf->SetAutoPageBreak(true, 20); $pdf->setCellMargins(0, 0, 0, 0); $pdf->setCellPaddings(0, 0, 0, 0); // Set default header/footer $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); // set default font subsetting mode $pdf->setFontSubsetting(true); $pdf->AddPage(); // Set some content to print $pdf->SetFont('Helvetica', 'B', 32); $pdf->SetTextColor(0, 0, 0); $pdf->Text(10,10, "Stock Check"); $pdf->SetXY(10, 30); $pdf->SetFont('helvetica', '', 9); $totalRows_rsB2Indigo > mysql_num_rows($rsB2Indigo); { $tbl = '<table style="width: 650px;" cellpadding="3" cellspacing="0">'; $tbl = $tbl . '<tr bgcolor="#CCCCCC"> <td style="border: 1px solid #000000; width: 60px; text-align:center"><strong>Id</strong></td> <td style="border: 1px solid #000000; width: 120px; text-align:center"><strong>Name</strong></td> <td style="border: 1px solid #000000; width: 60px;"><strong>Stock</strong></td> <td style="border: 1px solid #000000; width: 60px;"><strong>Allocated</strong></td> </tr>'; while($row_rsB2Indigo = mysql_fetch_assoc($rsB2Indigo,MYSQL_ASSOC)){ $id = $row_rsB2Indigo['material_id']; $name = $row_rsB2Indigo['material_name']; $Stock = $row_rsB2Indigo['material_stock']; $allocation = $row_rsB2Indigo['materia_allocated']; $tbl = $tbl . '<tr> <td style="border: 1px solid #000000; width: 60px; text-align:center"><strong>'.$id.'</strong></td> <td style="border: 1px solid #000000; width: 120px; text-align:center"><strong>'.$name.'</strong></td> <td style="border: 1px solid #000000; width: 60px;">'.$Stock.'</td> <td style="border: 1px solid #000000; width: 60px;">'.$allocation.'</td> </tr>'; } $tbl = $tbl . '</table>'; } // Print text using writeHTMLCell() $pdf->writeHTML($tbl, true, true, true, false, '');
-
Hi have a simple query which should retrieve 4 lines from database and display in HTML table but only 3 lines displaying??? This is the query which when I test works SELECT * FROM stock_material WHERE stock_material.material_catagory = 'B2 Indigo' AND stock_material.material_status = 'Active' See Screen shot from mySQL Database When the pdf is output it returns 3 results not 4 missing the first 1 This is the part generating the table $pdf->SetFont('Helvetica', 'B', 32); $pdf->SetTextColor(0, 0, 0); $pdf->Text(10,10, "Stock Check"); $pdf->SetXY(10, 30); $pdf->SetFont('helvetica', '', 9); $totalRows_rsB2Indigo > mysql_num_rows($rsB2Indigo); { $tbl = '<table style="width: 650px;" cellpadding="3" cellspacing="0">'; $tbl = $tbl . '<tr bgcolor="#CCCCCC"> <td style="border: 1px solid #000000; width: 60px; text-align:center"><strong>Id</strong></td> <td style="border: 1px solid #000000; width: 120px; text-align:center"><strong>Name</strong></td> <td style="border: 1px solid #000000; width: 60px;"><strong>Stock</strong></td> <td style="border: 1px solid #000000; width: 60px;"><strong>Allocated</strong></td> </tr>'; while($row_rsB2Indigo = mysql_fetch_assoc($rsB2Indigo,MYSQL_ASSOC)){ $id = $row_rsB2Indigo['material_id']; $name = $row_rsB2Indigo['material_name']; $Stock = $row_rsB2Indigo['material_stock']; $allocation = $row_rsB2Indigo['materia_allocated']; $tbl = $tbl . '<tr> <td style="border: 1px solid #000000; width: 60px; text-align:center"><strong>'.$id.'</strong></td> <td style="border: 1px solid #000000; width: 120px; text-align:center"><strong>'.$name.'</strong></td> <td style="border: 1px solid #000000; width: 60px;">'.$Stock.'</td> <td style="border: 1px solid #000000; width: 60px;">'.$allocation.'</td> </tr>'; } $tbl = $tbl . '</table>'; } // Print text using writeHTMLCell() $pdf->writeHTML($tbl, true, true, true, false, ''); I'm not sure where i'm going wrong, any help would be great
-
Hi, I running a query that groups merge.Description where the StoreId is the same, and replacing the comma with a line break. The problem I'm getting is the string only returns 1023 character's and I need it to return more? Any help would be great Cheers $rows = mysql_query("SELECT REPLACE(GROUP_CONCAT(merge.Description), ',', CHAR(13)) FROM merge GROUP BY merge.StoreId");
-
Hi thanks for help, i fixed this by group concat in the sql REPLACE(GROUP_CONCAT(merge.Description), ',', CHAR(13))
-
I added $data = []; and only this error now Connected successfully Warning: Invalid argument supplied for foreach() in /Applications/XAMPP/xamppfiles/htdocs/workflow/mergetest.php on line 19
-
Hi Thank you so much for help, the connection is working now but I get the following errors Connected successfully Warning: Invalid argument supplied for foreach() in /Applications/XAMPP/xamppfiles/htdocs/workflow/mergetest.php on line 18 Notice: Undefined variable: data in /Applications/XAMPP/xamppfiles/htdocs/workflow/mergetest.php on line 23 Warning: Invalid argument supplied for foreach() in /Applications/XAMPP/xamppfiles/htdocs/workflow/mergetest.php on line 23 <?php require_once('Connections/workflow-new.php'); ?> <?php error_reporting(E_ALL); ?> <?php ini_set('display_errors', '1'); ?> <!doctype html> <html> <head> <meta charset="UTF-8"> <title>Untitled Document</title> </head> <body> <?php $res = $conn->query("SELECT StoreId , Description FROM merge ORDER BY StoreId "); foreach ($res as $r) { $data[$r['StoreId']][] = $r['Description']; } echo "<table>\n"; foreach ($data as $store =>$prods) { echo "<tr style='vertical-align: top;'><td>$store</td><td>" . join('<br>', $prods) . "</td></tr>\n"; } echo "</table>\n"; ?> </body> </html>
-
Hi Sorry for delay had to deal with couple of issues!! Thanks for response, below is the connection script. <?php $servername = "localhost"; $database = "workflow"; $username = ""; $password = ""; try { $conn = new PDO("mysql:host=$servername;$database=myDB", $username, $password); // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); echo "Connected successfully"; } catch(PDOException $e) { echo "Connection failed: " . $e->getMessage(); } ?>
-
Hi Thanks for that I connect using require_once('../Connections/workflow.php'); <?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_workflow = "localhost"; $database_workflow = "workflow"; $username_workflow = " "; $password_workflow = " "; $workflow = mysql_pconnect($hostname_workflow, $username_workflow, $password_workflow) or trigger_error(mysql_error(),E_USER_ERROR); ?> Below is my database query mysql_select_db($database_workflow, $workflow); $query_rsTest = "SELECT merge.`Description`, merge.StoreId FROM merge GROUP BY merge.StoreId"; $rsTest = mysql_query($query_rsTest, $workflow) or die(mysql_error()); $row_rsTest = mysql_fetch_assoc($rsTest); $totalRows_rsTest = mysql_num_rows($rsTest);
-
Hi thank for response, I tried suggestion an I get the following errors Notice: Undefined variable: pdo in /Applications/XAMPP/xamppfiles/htdocs/workflow/mergetest.php on line 11 Fatal error: Call to a member function query() on null in /Applications/XAMPP/xamppfiles/htdocs/workflow/mergetest.php on line 11
-
Hi looking for some help with below issue I'm facing, any help would be great I have an SQL table call Merge with the below data in Id StoreId Description 1 B013 Alana 2 B013 Sleepmotion 3 B013 Sleepmotion 4 B013 Sleepmotion 5 B013 Hyde & Sleep 6 B017 Alana 7 B017 Isabella 8 B017 Sleepmotion 9 B017 Sleepmotion 10 B017 Sleepmotion 11 B017 Hyde & Sleep I'm trying to get the data to display as a table with description concatenated as below B013 Alana Sleepmotion Sleepmotion Sleepmotion Hyde & Sleep B017 Alana Isabella Sleepmotion Sleepmotion Sleepmotion Hyde & Sleep
-
Hi I'm trying to record the status of a user when they log out but I can't work out where I'm going wrong. Any help would be fantastic Cheers Chris Button <a href="<?php echo $logoutAction ?>">Log out</a> Log Out <?php //initialize the session if (!isset($_SESSION)) { session_start(); } // ** Logout the current user. ** $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true"; if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){ $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']); //Record log in and out Status $query=("UPDATE authorise SET authorise.authorise_status = 'Logged Out' WHERE authorise.authorise_username = '$_SESSION[MM_Username]'"); $result=mysql_query($query); } if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){ //to fully log out a visitor we need to clear the session varialbles $_SESSION['MM_Username'] = NULL; $_SESSION['MM_UserGroup'] = NULL; $_SESSION['PrevUrl'] = NULL; $_SESSION["skill"] = NULL; $_SESSION["email"] = NULL; $_SESSION["firstname"] = NULL; $_SESSION["department"] = NULL; $_SESSION["fullname"] = NULL; unset($_SESSION['MM_Username']); unset($_SESSION['MM_UserGroup']); unset($_SESSION['PrevUrl']); unset($_SESSION['skill']); unset($_SESSION['email']); unset($_SESSION['firstname']); unset($_SESSION['department']); unset($_SESSION['fullname']); $logoutGoTo = "../index.php"; if ($logoutGoTo) { header("Location: $logoutGoTo"); exit; } } ?>
-
Thank you so much, that was great and worked perfectly, is there any way of getting the Year in there as well? Cheers Chris
-
Hi, I'm trying to Select all records in my database based on month and count them. The dates are store as unix timestamp as below. So if I wanted to return all records for November 2019 the result would be 5 based on below. I have started the query as below but I'm not sure if DATEPART() is there correct way to finish. SELECT COUNT(Target) FROM production WHERE DATE(FROM_UNIXTIME(production.Target)) = Target ---------- 1574701200 1574701200 1574701200 1574701200 1574701200 1572436800 1572436800 1572436800 Cheers Chris (PHP/SQL Novice)
-
Ok that worked perfectly, thanks for help, if I wanted to use a date in the passed or future do use DATE_ADD() and DATE_SUB() instead of CURDATE() ? Once again thanks for help Cheers Chris
-
Thanks for response but still getting a 0 count when it should return a result, if I remove date part it works so issue is with how the query is comparing the stored unix date/time and the date today 2015-06-08??
-
-
Hi look for some help with querying based on todays date. I'm trying to count all the entries in the database based on username, status, date. The date bit is where I' stuck (see screen shot of database) Based on data in database I should get a count of 3 but get nothing?? The result I get is 0 and should be 3 based on date Any help would be a great help Cheers Chris //date bit $d=strtotime("today"); $wholedate2 = date("Y-m-d", $d); //query $query_rsUser = "SELECT COUNT(*) FROM quotes WHERE quotes.quote_user = 'username' AND quotes.quote_complete = '$date2' AND quotes.quote_status = 'Complete'";
-
I new that as well, can't see wood for trees sometimes, thanks
-
Hi, I could do with a bit of help with this, not sure where I'm going wrong. The following code is used to change the colour of a row based on date. I want to compare to todays date with the following results If < today (turns red) if == today (turns orange) if > today (turns green) I have included a screen shot of result I'm getting with below if statement <?php $requireddate = date('l jS F',$row_rsActiveQuotes['quote_requireddate']); //this is anthing before today's date if ($today < $requireddate) { echo '<tr class="tableBody2">'; } //this is anthing with today's date elseif ($today == $requireddate) { echo '<tr class="tableBody3">'; } //this is anthing with today's date elseif ($today > $requireddate) { echo '<tr class="tableBody1">'; } else //this is anthing from tommorow { echo '<tr class="tableBody4">'; } ?>
-
Hi, I'm stuck on below, I have a table called History that records date and time as timestamp, example attached below I'm trying to count the number of entries with todays date, below is the php for todays date and the query, Any one help point me in the write direction. $d=strtotime("today"); $wholedate = date("Y-m-d", $d); $date_array = explode('-', $wholedate); $date = mktime(0,0,0,(int)$date_array[1],(int)$date_array[2],(int)$date_array[0]); $query_rsWorkedToday = "SELECT COUNT(*) FROM history WHERE history_date = ‘$date’”;
- 7 replies
-
- select count
- date
-
(and 1 more)
Tagged with:
-
Thanks, do you know of examples using a drop down list?
-
I have a form that has a drop down list that gets company details from mysql database when the company name is selected. When the form is completed it will not submit??? If I remove the script that gets the data from the database i can submit the form? I'm not the best at javascript, so could do with pointing in the right direction!! Cheers Chris <script> function showCompany(str) { if (str=="") { document.getElementById("customerDetails").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("customerDetails").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getcustomer.php?customer_id="+str,true); xmlhttp.send(); } </script>
-
Thanks for help, I get a syntax error on all echo lines? Cheers Chris
-
Hi, Any help would be great I have the following code which is looking at two dates, due date and today. <?php[/font][/color][color=#232323][font='Helvetica Neue'] date_default_timezone_set('Europe/London');[/font][/color][color=#232323][font='Helvetica Neue'] $now = time();[/font][/color][color=#232323][font='Helvetica Neue'] if ($row_rsReleaseQue['duedate'] < date('d-m-Y',$now)) { echo '<tr class="tableBody3">'; } else { echo '<tr class="tableBody1">'; } ?> I want to change the background colour of the line in my table based on the due date. < less that todays date = Red (tableBody3) == equal to today = Orange (tableBody2) > greater than today = Green (tableBody1) Cheers Chris