Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

open a new browser window with PHP/MSQL 1

Status
Not open for further replies.

leegold2

Technical User
Oct 10, 2004
116
How would I do this -

I want to be able to click a hyperlink on an existing web page and have per what is hardcoded in the link (which I assume would be done with a Go or POST) a PHP/MYSQL DB query to take place, then I want a new browser window (I assume using TARGET="_blank) pop open with the results of the query.

Could someone give me a snippet or idea how this is done? Thanks.
 
Here is my interpretation of your scenario:

Let's say you have a table with a list of names. You want to be able to click on a name, which opens a new window, and displays the results of a query based on that name (or ID associated with that name).

Page 1:
Code:
$connection = connect_to_db(username,password);
$somequery = 'SELECT ID,NAME from table';
$results = mysql_query($somequery,$connection)
  or die('Query failed.');
while ($row=mysql_fetch_array($results)){
  $id = $row['ID'];
  $name = $row['NAME'];
  echo '<a href="details.php?id=$id" target="_blank">$name</a><br>';
}
Page 2 (details.php)
Code:
$connection = connect_to_db(username,password);
$id = $_GET['ID'];
$details_query = 'SELECT * FROM TABLE WHERE ID=$id';
$results = mysql_query($details_query,$connection)
  or die('Query failed.');
while ($row = mysql_fetch_array($results)) {
  $detail1 = $row['detail1'];
  $detail2 = $row['detail2'];
  ...
}
//display the details

Using the above example, you should be able to achieve what you are looking for.

[cheers]
Cheers!
Laura
 
When a user clicks a hyper link on an existing browser page I want the query results to open in a new browser page. It's a usability issue for the user, I need them to have the original page and the new page in view...
 
You'll have to require some sort of client side scripting support to open the new window, like JavaScript or something. Then you simply open the window with javascript and give it a URL with all the query parameters in a CGI GET.
 
Or:

Simply use a table, with either two rows or two cells..

either:
|--------|--------|
|original|modified|
|--------|--------|

or:
|--------------|
| original |
|--------------|
| modified |
|--------------|

remember: you can also use CSS and control overflow!

the way you would want it to be, would not work where user has popup blocker or does not support javascript.

The same type of error will also arrise for non-gui users!

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top