6 Replies - 397 Views - Last Post: 24 October 2017 - 09:36 AM Rate Topic: -----

#1 sunshinee  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 03-October 17

PROBLEM TO DISPLAY DATA USING DATE

Posted 23 October 2017 - 11:42 PM

I have problem to display the report based on date selection. User click "from" and "to" to click certain date in displaying the report.


<?php
			include('../db.php');
			//include("session.php");
			
			$a=$_POST['from'];
                        $b=$_POST['to'];
			
$result = mysql_query("SELECT d.date, d.no_kad, d.in_out, i.in_qty, i.in_unit_price, oc.in_total, ot.out_qty, oc.out_total, oc.blnce_qty, oc.blnce_total FROM stok_data d, stok_in i, stok_out ot, stok_outcome oc WHERE d.product_id=i.product_id AND oc.product_id=ot.product_id AND d.date BETWEEN '$a' AND '$b'");
			
			echo"<thead>";
			echo"<tr>
					<td width='100'>Tarikh</th>
   			       <td width='90'  align='center'>No.Kad</th>
				   <td width='200'  align='center'>Terima Daripada/Keluar Kepada</th>
				   <td width='50'  align='center'>Terimaan Kuantiti</th>
  				   <td width='80'  align='center'>Seunit(RM)</th>
				    <td width='80'  align='center'>Jumlah(RM)</th>
					<td width='50'  align='center'>Keluaran Kuantiti</th>
					 <td width='80'  align='center'>Jumlah(RM)</th>
					  <td width='80'  align='center'>Baki Kuantiti</th>
					   <td width='80'  align='center'>Baki Jumlah(RM)</th>
			    </tr>";
			echo"</thead>";
			
			while($test = mysql_fetch_array($result))
			{				
					echo "<tr>";	
					echo"<td  align='center'>" .$test['date']."</td>";
					echo"<td  align='center'>". $test['no_kad']. "</td>";
					echo"<td  align='center'>". $test['in_out']. "</td>";
					echo"<td  align='center'>". $test['in_qty']. "</td>";	
					echo"<td  align='center'>". $test['in_unit_price']. "</td>";	
					echo"<td  align='center'>" .$test['in_total']."</td>";
					echo"<td  align='center'>". $test['out_qty']. "</td>";
					echo"<td  align='center'>". $test['out_total']. "</td>";
					echo"<td  align='center'>". $test['blnce_qty']. "</td>";	
					echo"<td  align='center'>". $test['blnce_total']. "</td>";						
					echo "</tr>";
				
			}		
				
			mysql_close($con);
			mysql_error();
			?>



Is This A Good Question/Topic? 0
  • +

Replies To: PROBLEM TO DISPLAY DATA USING DATE

#2 andrewsw  Icon User is online

  • the case is sol-ved
  • member icon

Reputation: 6378
  • View blog
  • Posts: 25,769
  • Joined: 12-December 12

Re: PROBLEM TO DISPLAY DATA USING DATE

Posted 23 October 2017 - 11:56 PM

What problem? Is there an error? Post the error details.

Also print the values of $a and $b to see what you are working with, it is likely there is an issue with formatting of these values.

The mysql extension library should not be used, it has been deprecated for a long time and was removed from PHP 7. See my signature below for more information.

Also use prepared statements.

Note also that table elements no longer have width or align attributes, use CSS.
Was This Post Helpful? 0
  • +
  • -

#3 sunshinee  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 03-October 17

Re: PROBLEM TO DISPLAY DATA USING DATE

Posted 24 October 2017 - 12:22 AM

im trying to display data that have different db, but the problem with the code is the data cannot be displayed
Was This Post Helpful? 0
  • +
  • -

#4 sunshinee  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 03-October 17

Re: PROBLEM TO DISPLAY DATA USING DATE

Posted 24 October 2017 - 12:49 AM

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\istock\admin\filter.php on line 112

-->> PROBLEM & error to display the data <<----
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is online

  • the case is sol-ved
  • member icon

Reputation: 6378
  • View blog
  • Posts: 25,769
  • Joined: 12-December 12

Re: PROBLEM TO DISPLAY DATA USING DATE

Posted 24 October 2017 - 12:57 AM

mysql_query (which you should not be using) returns FALSE on error.

Again, print out the value of $sql, then also try to execute it in phpMyAdmin or similar.
Was This Post Helpful? 1
  • +
  • -

#6 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3714
  • View blog
  • Posts: 13,469
  • Joined: 08-August 08

Re: PROBLEM TO DISPLAY DATA USING DATE

Posted 24 October 2017 - 04:53 AM

Deprecated MySQL functions are simpler to use (not counting all the sanitizing you need to add) than PDO or MySQLi prepared statements, but far less secure. That's why they've been deprecated. If you're just learning PHP you should start with
http://www.dreaminco...duction-to-pdo/
or
http://php.net/manua...-statements.php
When dealing with old code that uses deprecated MySQL functions you should replace them if possible. If it's not possible, your experience with PDO or MySQLi will benefit you when dealing with MySQL functions.
Was This Post Helpful? 0
  • +
  • -

#7 benanamen  Icon User is offline

  • D.I.C Head

Reputation: 17
  • View blog
  • Posts: 131
  • Joined: 28-March 15

Re: PROBLEM TO DISPLAY DATA USING DATE

Posted 24 October 2017 - 09:36 AM

OP, your code is obsolete dangerous junk that has been completely removed from Php. You need to use PDO. There is no "Fixing" this code.

Here is a tutorial to get you going. Come back with the new code if you still have problems. PDO Tutorial
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1