0

Still green in php but I'm liking it. Anyways...

I have a table that retrieves information from my db which gets its data from a date search, so I want it to be retrieved in another table after being filtered.

I tried a couple of things including passing the variable that is being used in filtering it (date) into another window so that the table retrieves this information there with id as date from previous page.

On my search page i have this:

<?php
$tester = $_POST['Date'];
mysql_select_db($database_dbconnkk, $dbconnkk);
$query_equ = "SELECT * FROM daily_reports WHERE Date = '$tester' ORDER BY id ASC";
?>

And a table that repeats the same which is working. I have a link that opens window to this page with an attempt to retrieve data from previous test.

<?php
$tester2 = $_Get['Date'];

Also tried passing Date as id:

(id=<?php echo $row_equ['Date']; ?>)
Benjamin
  • 13
  • 3
  • 1
    Your code is terribly insecure. You are wide open to SQL injection and you **will be hacked** if you haven't been already. Learn to use prepared queries with PDO to avoid this problem. – Brad Aug 26 '12 at 22:54
  • @Brad: PDO? Why PDO specifically? Prepared queries -- yes; prepared queries *with PDO* -- why? – Bogdan Stăncescu Aug 26 '12 at 22:56
  • @Benjamin can you please provide an HTML of your link? – Viktor S. Aug 26 '12 at 22:57
  • @Gutza Because using mysqli you will eventually end up with ugly hacks like this http://stackoverflow.com/questions/11533512/phps-mysqli-prepare-generate-dynamically/11533605#11533605 – Kris Aug 26 '12 at 22:58
  • @Kris: true, but that's a false dilemma. – Bogdan Stăncescu Aug 26 '12 at 22:59
  • @Brad thanks but i am still working on my coding...not very good – Benjamin Aug 26 '12 at 23:00
  • @Gutza Aside from PDO and mysqli, are there other PHP libraries that 1) do prepared queries, 2) are available to novices by default, and 3) talk to mysql? – octern Aug 26 '12 at 23:01
  • @octern About a gazillion, but all fail on (2). However, I'm not sure (2) needs to be an inherent assumption in all conversations, leading invariably to the least common denominator. That was in fact my original point. One can say "Use prepared queries -- PDO is quite good at that" instead of "Use prepared queries with PDO". – Bogdan Stăncescu Aug 26 '12 at 23:07
  • @Gutza, I completely agree! Prepared queries with anything are the way to go. I suggest PDO, as I believe it is more useful to folks as they learn. Then, they can stick to one common API, even if they drop MySQL in the future. Certainly there are more ways to skin this cat, but I've found if you try to explain that in a comment, the whole thing just gets ignored. Your suggested phrasing is solid, and I will likely use that in future comments. – Brad Aug 26 '12 at 23:30

2 Answers2

1

Suppose problem is here:

$tester2 = $_Get['Date'];

Variable names are case sensitive in PHP, so this line should look like:

$tester2 = $_GET['Date'];

instead. Everything else looks like it should work.

Viktor S.
  • 12,736
  • 1
  • 27
  • 52
  • is there any other method i can use to get this filtered data from memory to another page? – Benjamin Aug 26 '12 at 23:32
  • What do you mean under 'get this filtered data from memory to another page'? As I understand, you are need to show details of selected daily report. You are sending the date and in the modify.php you should use it to take corresponding details from database. I think it would be better if you post a code of your modify.php, because currently the only problem I see is misspeled $_Get – Viktor S. Aug 26 '12 at 23:38
  • ok this is where i am at:- //daily report.php – Benjamin Aug 26 '12 at 23:48
  • /modify.php – Benjamin Aug 26 '12 at 23:49
  • Well, first of all - you alsways can edit your post and put your code into a code block (reading of code like it is above in your comments is just a pain :) ). – Viktor S. Aug 26 '12 at 23:52
  • Second - it is not clear where you have a problem. then table that shows records of the records but gives an error if before submit - here it looks like you have this error when page is opened before submit. Than take a look at `isset`. This way you can check if there is a Date in `$_POST`. And also I see that window.open goes to close.php - is that correct? And also you have id there instead of Date – Viktor S. Aug 27 '12 at 00:01
0

i got it. passed the date i was using on the filter in the same variable i was using to filter the records

?Date=<?php echo $tester; ?>

then on my new window i get the same into another variable(tester2)

$tester2 = $_GET['Date'];

select then echo in columns

$query_equ = "SELECT * FROM daily_reports WHERE Date = '$tester2' ORDER BY id ASC";
Benjamin
  • 13
  • 3