Jump to content

Display query based off selection on child page


chutchick

Recommended Posts

Good day and Merry Christmas to all,

 

I just spent a good time of my christmas eve trying to figure out this problem. I hope one of you santas would be so kind as to help me with it.

 

First off I have two tables; employee and employee_works both connected via employee_id key.

 

Basically I have a parent window we'll call parent.php.

inside the parent page is a search button that once clicked will open a child window we'll call child.php

 

inside the child page is a list, lets say employees with name, employee_id, etc.

 

My main concern is this:

How do I populate parent.php based off the employee selection I made in the child window.

 

Example:

-Access parent.php

-Click on search

-Click on [iD: 004] [NAME: JOHN SMITH] [PHONE: 1233456] [DATE HIRED: JULY 16, 1992] <---format of a row in child.php

-child.php automatically closes and parent.php now shows all data from employee_works with the employee_id = 004

 

Is this even possible? I know this is vary vague and would be willing to explain more if needed. My website is built mostly on javascript and php.

Link to comment
Share on other sites

so lets say i assign a $session[id] = 4;

then i call a javascript function to close the child window and window.opener.reload() to refresh the parent window.

then on the parent window i add something like:

 

if($session[id])

{

//code for employee_works here

}

 

would this be ok?

Link to comment
Share on other sites

Ive got it down to:

 

if($_SESSION["ledger"])

{

$led = $_SESSION["ledger"];

$sql = mysql_query("SELECT * FROM employee_works WHERE employee_id = $led");

 

while($row = mysql_fetch_array($sql))  <--this is line 113

  {

  echo "<tr>";

  echo "<td align='center' width='300'>" . $row['employee_work_des'] . "</td>";

echo "<td align='center' width='300'>" . $row['employee_work_time'] . "</td>";

                echo"</tr>";

  }

echo "</table>";

 

 

its giving an error:

Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in C:\xampp\htdocs\beta\function\ledger.php on line 113

Link to comment
Share on other sites

That error means that code is not the actual code that is producing that error.

 

string given

 

^^^ Means that the variable or literal value you supplied to the mysql_fetch_array() statement is a string. The posted code would have supplied a result resource if the query executed without any errors or a boolean false value if the query failed to execute due to an error. The only way the posted code could have supplied a string to the mysql_fetch_array() statement would be if there was a statement like - $sql = "a statement producing a string";, either somewhere between the mysql_query() statement and the start of the while(){} loop or somewhere in the actual code inside the while(){} loop.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.