|
|
Post a Project »
Find a Professional HTML Freelancer!
Find a Freelancer to help you with your HTML projects
| |
|
Creating a Results Page in a Master/detail Frameset
05-25-2005, 12:53 PM
|
Creating a Results Page in a Master/detail Frameset
|
Posts: 36
|
Hello all. Hope you are doing well. I have a problem (again). Any advice or thoughts would be fantastic.
I am designing a simple PHP search engine which takes records from my database depending on the search criteria entered.
It works in the sense that after submit is selected, then next page reveals a list of the records matching the selected criteria. This is good….but
I want to press [SUBMIT] and be taken to a 2 frame frameset. On the right hand frame is the list of record fields which the search produced. Clicking on these records fields will display more details of this record in the left hand page (like a Master/Detail page).
However, I am having problems getting this to work. My failings are this:
If the results page (results.php) is the right hand side page in the frameset, after I have pressed [SUBMIT] on the search page, I am taken directly to the results.php page (the frameset I put it in is by-passed).
If I make the GET ACTION method from the search page the actual frameset itself, then the right hand side (results/master) page does not list the criteria specified by the search, but just the top entries in the database.
Right, that probably made very little sense. I apologize for my poor explanation. I think I just want to know if you can display results from a search in the right hand column of a frameset.
ANY advice or opinions would be welcomed. I wonder if I should even be doing this with frames. I can’t really program so have been using them as I don’t really know what else to use. If you think I should be doing this a different way please let me know.
Thanks all 
|
|
|
|
05-25-2005, 08:15 PM
|
|
Posts: 237
|
I think if I was you, I would use tables instead. I haven't used frames in any of my design's for quite a long time simply for the same reason - they are a pain in the butt! It doesn't matter if you are using an HTML editor or handcoding, tables are easy to learn to code. There are tons of links on how to use tables for layout, I would suggest doing a Google search and see what you come up with. The sooner you get away from frames, the better in my opinion.
Kaiman
Glenwood Springs, CO - Website Design and Graphics
|
|
|
|
05-25-2005, 09:06 PM
|
|
Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
|
frames are evil and I'll edit in a response, I just asked a q'n that was answered on a 2nd read of ur post...
brb
Last edited by metho; 05-25-2005 at 09:10 PM..
|
|
|
|
05-25-2005, 10:51 PM
|
|
Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
|
This sounded like a feature I could adapt for a current project. The script I came up with looks like so (just substitute the db connect file, db table-column names and echoed output to whatever you like)
PHP Code:
<?php
require_once('../yourDBconnFile.php');
//
if(isset($_POST['term'])){
$search = $_POST['term'];
}
if(isset($_GET['show'])){
$search = $_GET['term'];
}
if(isset($_POST['term']) || isset($_GET['show'])){
mysql_select_db($yourDB, $dbConn);
$sql = "SELECT userID, firstName, email FROM table_users WHERE firstName LIKE '%".$search."%' OR email LIKE '%".$search."%'";
$result = mysql_query($sql, $dbConn);
$row = mysql_fetch_assoc($result);
$user_name = $row['firstName'];
$email_address = $row['email'];
$id = $row['userID'];
}
//
?>
<html>
<head>
<title>search form</title>
<style type="text/css">
<!--
#results {
vertical-align: top;
}
-->
</style>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?search=done" method="post" name="search" id="search">
<input name="term" type="text" id="term" size="25">
<input type="submit" name="Submit" value="Go">
</form>
<?php
// show search result table
if(isset($_POST['term']) || isset($_GET['show'])){
?>
<table width="450" border="0" cellspacing="2" cellpadding="2">
<tr>
<td>Click Search Results for Details </td>
<td>Result Details </td>
</tr>
<?php
if (isset($_POST['term']) && (!$result)) {
// no results, echo as such
?>
<tr>
<td colspan="2"><b>No Results.</b> Please contact try another search term.</td>
</tr>
<?php }
// end show no result msg
else{ ?>
<tr>
<td>
<?php
$i=0;
do{
$i++;
?>
<p><a href="<?php echo $_SERVER['PHP_SELF']; ?>?show=<?php echo $row['userID'].'&term='.$search; ?>">Result <?php echo $i; ?></a><br />
<?php
} while($row = mysql_fetch_assoc($result));
}
?>
</p>
</td>
<td id="results">
<?php
if(isset($_GET['show'])){
$rID = $_GET['show'];
$sql2 = "SELECT firstName, email FROM table_users WHERE userID = '".$rID."'";
$result2 = mysql_query($sql2, $dbConn);
$row2 = mysql_fetch_assoc($result2);
$user_name = $row2['firstName'];
$email_address = $row2['email'];
echo $row2['firstName']." :: ".$row2['email'];
?>
</td>
</tr>
<?php } ?>
</table>
<?php }
// end show search result table
?>
</body>
</html>
|
|
|
|
05-26-2005, 03:45 AM
|
|
Posts: 36
|
Thanks a lot for that Kaiman and Metho. I'll try to edit that script metho, and also I'll try to learn how to use tables instead of frames. Thanks guys
|
|
|
|
05-26-2005, 04:10 AM
|
|
Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
|
just reply to this thread if you need any help customizing it for your site jool...
|
|
|
|
05-26-2005, 10:49 AM
|
|
Posts: 36
|
Thanks again Metho. I must warn you however, I have no experience of hand-coding or scripting but will certainly do my best - and try not to pester you with too basic questions
To ensure that your script does what I hope mine will do, is there a url online where I could look at it in action?
I basically want to go from a page containing a small search box (on my home page) to a page split in 2 with the right hand side of the page (MASTER) listing names and the left hand side (DETAIL) listing that persons profile.
Thanks again.
|
|
|
|
05-26-2005, 09:18 PM
|
|
Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
|
jool - I've pm'ed you the URL. Remember that the 'master' and 'detail' information can be tailored to anything...
|
|
|
|
05-27-2005, 03:39 PM
|
|
Posts: 36
|
Hi metho - cheers for that. I have to confess I couldn't quite follow the code and tailor it to what I needed, so I started again with a different method. I used 2 Div layers and the search screen displaying the results of the search (carried out on a previous screen) on the right hand 'Master' page.
This all seemed to work with the details then displayed on the main 'Detalis' layer. However the one problem is that after I select a record from the list of Master values, the list refreshes and no longer displays a list of the records defined by the search, but instead just displays the default values which I specified in my recordset. I tried to take out the default value (and also tried to use the value that was entered as the default) but what then happens is when something is selected the list just refreshes and then displays nothing (as nothing is the 'default')
Does this make sense? Anyway - thanks a lot for your help, and I'm sorry I wasn't skilled enough to understand your solution. What I have now almost works, and I think I am close to getting it - I basically want the input search values to remain the default values........
I think the problem code is this part :
$varlanguage_s = "English";
if (isset($language)) {
$varlanguage_s = (get_magic_quotes_gpc()) ? $language : addslashes($language);
}
$varprefecture_s = "Tokyo";
if (isset($prefecture)) {
$varprefecture_s = (get_magic_quotes_gpc()) ? $prefecture : addslashes($prefecture);
with English and Tokyo the default values....
Anyway, thanks again for all your help.
Cheers
|
|
|
|
05-27-2005, 10:32 PM
|
|
Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
|
jool - the biggest barrier we have here is termanology. Part of the problem is that your not articulate enough in php/html termanology to describe the specifics of the situation. That'll come in time
Without seeing your complete multi-page source, I can safely make a call that the problem lies in your search term and detail record id being lost after submitting the search form or clicking a master-link to display a detailed record.
This happens because each time you make a page load, previous values are lost unless they are resent within the header to the requested page or within the URL as name/value pairs. To counteract this, you must ensure that the values are resent to the newly loading page AND that your recordsets are geared to pick up on the methods you use to submit values to the database queries.
This problem would be easier to help with if I knew how you are generating your code. Are you sloggin it by hand or using an editor such as Dreamweaver?
|
|
|
|
05-28-2005, 03:23 PM
|
|
Posts: 36
|
Thanks for the response again Metho. You're completely right about me not being able to explain myself correctly and I believe this is partly because I myself don't really know what I am doing.
I do everything more or less through Dreamweaver (I can't really script even the most basic things) using it's Dynamic Application toolbars and functionality.
My set-up consists of a simple form page with two search fields. Using the GET Method, the search Parameters are sent to another PHP page featuring two Div Layers ('Master and Detail') The search parameters are affective initially but 'lost ' on refresh.
If you like I could send you the code or even the website pages in particular - although of course I don't want to take up too much of your time.
I'll continue to work on it. Thanks again for your help.
Cheers
|
|
|
|
05-28-2005, 06:30 PM
|
|
Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
|
Na - dont send me the code. If you do I'll feel obliged to charge for a private consult. Just post the php code, above the html of the pages and the tables/forms with php inside, in here. That way it's a public call for help. This is standard procedure for helping developers via a public forum. And don't worry about security. The important settings for your site are kept in a separate folder called "Connections"; dont post any code from inside files in that folder....
And dont feel as though ur asking too much either, I freely give my time, as do many other professional and hobbiest devs, to help out others in here and other forums.
Last edited by metho; 05-28-2005 at 06:32 PM..
|
|
|
|
05-29-2005, 06:24 AM
|
|
Posts: 1,611
Name: Michael (mik) Land
Location: England
|
Wrong forum. You might get more advice from the PHP/MySQL section.
__________________
Please login or register to view this content. Registration is FREE - Tumblog with thoughts, quotes, links, videos, images and my creations.
Please login or register to view this content. Registration is FREE - The best free web browser.
Please login or register to view this content. Registration is FREE - Firefox is now Firefail.
|
|
|
|
05-29-2005, 02:33 PM
|
|
Posts: 36
|
Thanks Metho - I'll probably move this posting later Twitch , I'm just not sure if my problem is MySQL / PHP related or just something to do with HTML...
The code for the Form submit page is simply:
<form action="Lisa1.php"rightFrame" " method="get" name="form1">
<p>
<select name="language" id="language">
<option value="English">English</option>
<option value="French">French</option>
<option value="Spanish">Spanish</option>
<option value="Chinese">Chinese</option>
<option value="German">German</option>
</select>
...
(And also the same for prefectures in Japan)
The page it submits the seacrh results to (Lisa1.php - The Master / Details page) is
<?php require_once('Connections/connectiona.php'); ?>
<?php
$colname_b = "1";
if (isset($_GET['recordID'])) {
$colname_b = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
}
mysql_select_db($database_connectiona, $connectiona);
$query_b = sprintf("SELECT autonumber, sex, firstname, fullname, age, nationality, `language`, OthLanguage, teachingexperience, LangSchls, LangQual, qualifications, otherexper, TMethd, jap_ability, likes, dislikes, fav_movie, areas, prefecture, mm, ma, me, tm, ta, te, wm, wa, we, thm, tha, the, fm, fa, fe, sm, sa, se, `sum`, sua, sue, private_price, group_price, message, contactmail, contactnum FROM TestTable WHERE autonumber = %s", $colname_b);
$b = mysql_query($query_b, $connectiona) or die(mysql_error());
$row_b = mysql_fetch_assoc($b);
$totalRows_b = mysql_num_rows($b);
$maxRows_s = 30;
$pageNum_s = 0;
if (isset($_GET['pageNum_s'])) {
$pageNum_s = $_GET['pageNum_s'];
}
$startRow_s = $pageNum_s * $maxRows_s;
$varlanguage_s = "English";
if (isset($language)) {
$varlanguage_s = (get_magic_quotes_gpc()) ? $language : addslashes($language);
}
$varprefecture_s = "Tokyo";
if (isset($prefecture)) {
$varprefecture_s = (get_magic_quotes_gpc()) ? $prefecture : addslashes($prefecture);
}
mysql_select_db($database_connectiona, $connectiona);
$query_s = sprintf("SELECT TestTable.autonumber, TestTable.firstname, TestTable.nationality, TestTable.private_price, TestTable.sex FROM TestTable WHERE TestTable.`language`= '%s' AND TestTable.prefecture = '%s' ", $varlanguage_s,$varprefecture_s);
$query_limit_s = sprintf("%s LIMIT %d, %d", $query_s, $startRow_s, $maxRows_s);
$s = mysql_query($query_limit_s, $connectiona) or die(mysql_error());
$row_s = mysql_fetch_assoc($s);
if (isset($_GET['totalRows_s'])) {
$totalRows_s = $_GET['totalRows_s'];
} else {
$all_s = mysql_query($query_s);
$totalRows_s = mysql_num_rows($all_s);
}
$totalPages_s = ceil($totalRows_s/$maxRows_s)-1;
?>
<html>
.....
'Tokyo' and 'English' are the default values I specified (if no values are entered in the search box), and the problem is that after I click on a record brought up by the search parameters, the list then displays those Tokyo and English default values - and no longer the list created due to the search.
Thanks again, and I'll let you all know if I make any progress...
|
|
|
|
05-30-2005, 08:31 AM
|
|
Posts: 36
|
I'll now try this - as Twitch suggested - in the PhP area. I've put a test version of what I am trying to do on the internet at
http://www.orangutanenglish.com/complexsearchpage1.htm
I guess it explains better than what I was trying to do.
Anyway thanks Kaiman, Metho and Twitch for the help
|
|
|
|
05-30-2005, 05:43 PM
|
|
Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
|
will post any further comments in php forum...
|
|
|
|
|
« Reply to Creating a Results Page in a Master/detail Frameset
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|