Jump to content

cyberRobot

Moderators
  • Posts

    3,145
  • Joined

  • Last visited

  • Days Won

    37

Everything posted by cyberRobot

  1. Have you tried adding another <option> tag right after the open <select> tag? The value attribute would be set to blank. <option value="">Choose One</option>
  2. Try setting the width for the anchor tag. .submenu a { padding-top:4%; display:inline-block; width:200px; }
  3. This echo "<option value=".$squadre[$num5]." " Needs to be changed to something like this echo "<option value='".$squadre[$num5]."' " Of course, that doesn't address the security issues mentioned by Jacques1.
  4. Have you tried removing the extra HTML? For "bs_kf_production_price_week.php", instead of <html> <head> <title>Production</title> </head> <body> <div class="wrapper"> <?php $grandTotal = 0; $connect =odbc_connect("removed"); if(!$connect) { exit("Connection Failed: " . $connect); } $sql=" SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, tdate)) AS DATE ,ISNULL(trans, 'NON') AS trans ,ISNULL(Transactions.item, Snumbers.item) AS item ,count(serial) AS qty ,tuser ,sum(M1_KF.dbo.PartUnitSalePrices.imhUnitSalePrice) as TotalPrice FROM Orbedata.dbo.SNumbers LEFT OUTER JOIN OrbeData.dbo.Transactions ON snum = serial INNER JOIN M1_KF.dbo.PartUnitSalePrices ON Orbedata.dbo.transactions.item = M1_KF.dbo.PartUnitSalePrices.imhPartID WHERE tdate>=DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0) and tdate<=DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6) AND trans = 'fpr' GROUP BY DATEADD(dd, 0, DATEDIFF(dd, 0, tdate)) ,ISNULL(trans, 'NON') ,ISNULL(Transactions.item, Snumbers.item) ,tuser ,Orbedata.dbo.transactions.qty order by tuser,item "; $result =odbc_exec($connect,$sql); if(!$result){ exit("Error in SQL"); } while (odbc_fetch_row($result)) { $scanner=odbc_result($result,"tuser"); $Item=odbc_result($result,"item"); $Qty=odbc_result($result,"qty"); $Price=odbc_result($result,"TotalPrice"); $num = number_format($Price, 2); $grandTotal += $Price; $num2 = number_format( $grandTotal, 2); } odbc_close($connect); echo "$num2"; ?> </div> </body> </html> Try <?php $grandTotal = 0; $connect =odbc_connect("removed"); if(!$connect) { exit("Connection Failed: " . $connect); } $sql=" SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, tdate)) AS DATE ,ISNULL(trans, 'NON') AS trans ,ISNULL(Transactions.item, Snumbers.item) AS item ,count(serial) AS qty ,tuser ,sum(M1_KF.dbo.PartUnitSalePrices.imhUnitSalePrice) as TotalPrice FROM Orbedata.dbo.SNumbers LEFT OUTER JOIN OrbeData.dbo.Transactions ON snum = serial INNER JOIN M1_KF.dbo.PartUnitSalePrices ON Orbedata.dbo.transactions.item = M1_KF.dbo.PartUnitSalePrices.imhPartID WHERE tdate>=DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0) and tdate<=DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6) AND trans = 'fpr' GROUP BY DATEADD(dd, 0, DATEDIFF(dd, 0, tdate)) ,ISNULL(trans, 'NON') ,ISNULL(Transactions.item, Snumbers.item) ,tuser ,Orbedata.dbo.transactions.qty order by tuser,item "; $result =odbc_exec($connect,$sql); if(!$result){ exit("Error in SQL"); } while (odbc_fetch_row($result)) { $scanner=odbc_result($result,"tuser"); $Item=odbc_result($result,"item"); $Qty=odbc_result($result,"qty"); $Price=odbc_result($result,"TotalPrice"); $num = number_format($Price, 2); $grandTotal += $Price; $num2 = number_format( $grandTotal, 2); } odbc_close($connect); echo "$num2"; ?>
  5. Is the code for all / most of the pages very similar...maybe a different database name here and a table name there? If so, you could look into creating a function using the code used by all / most of the scripts. And then pass any specific information, like a table name, as function arguments.
  6. Side note: have you considered putting the database connection code into a separate include file? That way you could import the code as need. And you would only need to update the database password, for example, in one location.
  7. Is there a reason for including all the HTML tags? It seems like the include file could be cut down to something like this: <?php $grandTotal = 0; $connect =odbc_connect("removed"); if(!$connect) { exit("Connection Failed: " . $connect); } $sql=" SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, tdate)) AS DATE ,ISNULL(trans, 'NON') AS trans ,ISNULL(Transactions.item, Snumbers.item) AS item ,count(serial) AS qty ,tuser ,sum(M1_KF.dbo.PartUnitSalePrices.imhUnitSalePrice) as TotalPrice FROM Orbedata.dbo.SNumbers LEFT OUTER JOIN OrbeData.dbo.Transactions ON snum = serial INNER JOIN M1_KF.dbo.PartUnitSalePrices ON Orbedata.dbo.transactions.item = M1_KF.dbo.PartUnitSalePrices.imhPartID WHERE tdate>=DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0) and tdate<=DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6) AND trans = 'fpr' GROUP BY DATEADD(dd, 0, DATEDIFF(dd, 0, tdate)) ,ISNULL(trans, 'NON') ,ISNULL(Transactions.item, Snumbers.item) ,tuser ,Orbedata.dbo.transactions.qty order by tuser,item "; $result =odbc_exec($connect,$sql); if(!$result){ exit("Error in SQL"); } while (odbc_fetch_row($result)) { $scanner=odbc_result($result,"tuser"); $Item=odbc_result($result,"item"); $Qty=odbc_result($result,"qty"); $Price=odbc_result($result,"TotalPrice"); $num = number_format($Price, 2); $grandTotal += $Price; $num2 = number_format( $grandTotal, 2); } odbc_close($connect); echo "$num2"; ?> Or better yet, you could create your own function using the above code and then returning the value of $num2. More information about creating functions can be found here: http://php.net/manual/en/functions.user-defined.php
  8. What does the code for "bs_kf_production_price_week.php" look like?
  9. That works when running the queries at the "localhost" level. However, it doesn't seem to do anything when running queries at the database level in phpMyAdmin. It doesn't flag an error. It just seems to ignore that statement altogether.
  10. Huh...option 3 actually works! It doesn't seem to matter which database I'm in when clicking the SQL tab and running the query. And the technique even works at the "localhost" level. For what it's worth, the "USE databasename" option didn't work. If you're in the wrong database, an INSERT query, for example, still works if that database happens to have a table with the same name used in the query. I was hoping the phpMyAdmin would at least flag the error. Thanks Barand!
  11. When running a query in phpMyAdmin, is there a way to make sure the correct database is selected before executing the query? I know that the following code lets you see which database is selected: SELECT DATABASE(); But I'm not sure how to use the information to prevent queries from running when the wrong database is selected.
  12. If you are asking how to get the information from the form, you would use $_POST. More information can be found here: http://php.net/manual/en/reserved.variables.post.php
  13. To fix the error handling, see Example #1 here: http://php.net/manual/en/function.mysql-query.php Of course, you will want to move away from the mysql_* functions as soon as possible, as benanamen and Jacques1 have suggested.
  14. It looks like you are using the file() function as an array here: $data = file('Images/'.$id.'.txt')[10]; I imagine the "[10]" part isn't necessary.
  15. Did you write the code? If not, where does the code come from?
  16. Welcome ris_geek82! And congratulations on the family!
  17. Based on the code shown, $orderInfo isn't defined. It looks like all the data is stored in the following arrays: $sample1_received $sample2_received $sample1_completed $sample2_completed What would you like to happen in the following line? $csvLine = array( 'DATE' => $orderInfo[''], 'SAMPLE1 ITEMS RECEIVED' => $orderInfo[''], 'SAMPLE1 ITEMS COMPLETED' => $orderInfo[''], 'SAMPLE2 ITEMS RECEIVED' => $orderInfo[''], 'SAMPLE2 ITEMS COMPLETED' => $orderInfo[''], ); Are the values, where you currently have $orderInfo[''], supposed to be a string...or an array? Side note: the mysql_ functions were removed in the latest release of PHP. You will want to use a different API soon. More information can be found here: http://php.net/manual/en/mysqlinfo.api.choosing.php
  18. You could define all the icons you want to use, like what was done here: var icon = new google.maps.MarkerImage("http://maps.google.com/mapfiles/ms/micons/blue.png", new google.maps.Size(32, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 32)); And then modify the addMarker() function to accept a new parameter to use when choosing the icon to display. The while loop which calls addMarker() would then be modified to say which icon to use. Side note: the mysql_* functions have been removed from the newest version of PHP. You'll want to switch as soon as possible. More information can be found here: http://php.net/manual/en/mysqlinfo.api.choosing.php
  19. ...assuming that's all the OP wants to do. But good point.
  20. You are missing some quotes and other components. You could try the following: <?php $database = array(); $database['host'] = "localhost"; $database['port'] = '3306'; $database['name'] = "forumtest"; $database['username'] = "root"; $database['password'] = "Password"; $link = mysql_connect($database['host'], $database['username'], $database['password']); if ($link) { echo "Connected to a database".$database['name']; }else{ echo "connect to a database" . $database['name'] . "failed<br/>"; echo "Error: ".mysql_error(); } ?> With that said, the mysql_* functions were removed in the newest version of PHP, as benanamen was hinting at. More information can be found here: http://php.net/manual/en/mysqlinfo.api.choosing.php
  21. Every time the loop executes, the $products variable is being overridden. So the output will only contain the last record. You could try something like this: $products = array(); while($list_products = mysql_fetch_assoc($query_products)) { $products[]['id'] = $list_products['id']; $products[]['status'] = $list_products['status']; $products[]['code'] = $list_products['code']; $products[]['name'] = $list_products['name']; $products[]['amount'] = $list_products['amount']; $dump = array(); } And then use a foreach loop to output the products.
  22. I imagine the error is displayed when you first visit the form...before submitting it? Is that correct? Basically, the $_POST variable is only populated after the form is submitted. To determine if a form (set to POST) is submitted, you can use the following: if($_SERVER['REQUEST_METHOD'] == 'POST') { $errorMessage = ""; //...
  23. Are you getting the information from a MySQL database? If so, you could indicate an offset and the number of rows you want in the LIMIT clause. More information can be found here: http://dev.mysql.com/doc/refman/5.7/en/select.html Of course, you would need to figure out what that offset should be. You could determine that using the number of results per page (3000) and a variable that indicates which page the user is on...assuming that you are talking about a pagination script.
  24. Note that the above string contains a variable. If you enclose the string within single quotes, the variable will not work.
  25. To get the first element in an array, you could use array_shift(). More information can be found here: http://php.net/manual/en/function.array-shift.php With that, you probably don't need the foreach loop. But I'm not sure if that solves the second part of your question.
×
×
  • 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.