Click to See Complete Forum and Search --> : generate links
moondance
07-30-2003, 03:20 AM
with my php script, it retrieves customer complaint information from a database and lists them on screen. The information it retrieves are like customer records, about 8 fields in total, such as name, date, error reported etc.
Does anyone know how to show just a few fields or a short description, with a link to open the full description in a new window?
ta
I'd make two PHP pages. The first lists the complaints in the short form that you desire, and the second will display everything. Then, what you will need to do is link to the second page with a query string attached, and this will tell the page which record to show.
moondance
07-30-2003, 07:29 AM
that sounds a bit complicated - know of any tutorials on the subject?
Hmm... not really. None on that exact subject. It really shouldn't be that hard, as long as you know how to get the records out of the database. On the first page, you will want to display everything that is in the database, with the exception of the complaint (or perhaps just a few words of the complaint). Then, on the second page, you will want to show all the fields for the one specific complain, including the full text of the complaint.
moondance
07-30-2003, 09:40 AM
i've made the first page display a summary of fields, along with a link to a second page, that can display all the fields and information.
Problem is, how do i pass the id of the item the user clicked on from the first page to the second - as in how can i tell the second page what item to retrieve?
When you are writing the links in with PHP, just include them in the <a href> something like this:
<a href="yourpage.php?id=$var">text</a>
and then to get that value on yourpage.php, you can use $_GET["id"];
moondance
07-30-2003, 10:17 AM
i've put the value in the link tag like you said, but i'm not sure if its not working from the link or at the second page.
heres some of my code:
this is on the first page, that displays the summaries:
$index = $row ["complaintID"];
echo "<a href = detailed.php?id = $index>" . $row ["problemSummary"] . "</a>";
When i click on the link, it send the index as part of the url for the detailed.php page.
in the detailed.php page, i simply have ( to check its recieving the $index):
echo "Your Complaint ID is: " . $_GET["index"];
but its not retriveing the $index - where am i going wrong?
echo "Your Complaint ID is: " . $_GET["index"];
should be
echo "Your Complaint ID is: " . $_GET["id"];
as we assigned the GET variable "id" to equal the value of $index.
moondance
07-30-2003, 10:53 AM
i seeeeeeeeeeeeeee..........yep thats working great now.
Thanks for your help today pyro
;)
You are very welcome... ;)
moondance
09-19-2003, 09:04 AM
sorry to bring up another old post, but i don't want to start a new one on the subject, when all the info is above.
Theres two sections to the site, a private section and a global section. In these sections, customer complaints are displayed in tables. In the private secton, the content is specific to the login name, and in the global section, the content is all the complaints from all users.
Using the above code:
$index = $row ["complaintID"];
echo "<a href = detailed.php?id = $index>" . $row ["problemSummary"] . "</a>";
Then on detailed.php, to retreive and display the complete complaint form:
$result = mysql_query("select * from complaints where complaintnumber = ' $_GET[id]' ")
I've just been told that in the private section, the complaintnumber is unique, but in the public section, there may be more than one of the same complaintnumber.
Using this script works fine for the private section, but when in the public section, it will retreive and display two or more complaints if they have the same id.
by adding into the mysql statement:
AND customerid = $Name
will only then retreive the complaint of the name the user logged in as, therefore defeating the point of having a global complaints section.
I've also tried LIMIT 1, but it only retreives the first one it finds.
Is there any way around this?
I'm not sure what it is that you need to try to do...
moondance
09-19-2003, 09:59 AM
ok, say theres the personal section:
xxx's complaint's:
---------------------------
id|description|status |
---------------------------
5|description|complete|
7|description|complete|
9|description|complete|
---------------------------
this is displayed on the page as a table. "Description"'s are links, that will open up in a new window the full details of that entry.
Now if they are in the global section, there may be entries with the same id:
all companies complaints:
----------------------------
id|description|status |
----------------------------
4|description|complete |
8|description|complete |
5|description|complete |
5|description|complete |
4|description|complete |
----------------------------
as this section is made up of entries from more than one client.
Now the code for the detail.php page, to display the full description of the complaint uses the id as one of the conditions in the sql lookup:
select * from complaints where complaintnumber = $_GET['id']
So now, if the user clicks on id 5, the detail page will open, with two entries in it - both the id5 entries.
I need this detail page to open only the entry clicked on, but am boggled on how to do so.
thanks for your time anyhow pyro
:confused: :(
You are going to need to either use some sort of unique ID (which is what I would recommend) or also match by something other than just the id...
moondance
09-19-2003, 10:06 AM
i was just this second thinking -
how about a check, that if the id's are the same, then it matches, say the first 10 characters of the description - i think this would work, but not sure how.
If you know what the first 10 characters of the description are, I suppose it would work. Not how I would do it, though.
moondance
09-19-2003, 10:19 AM
you reckon theres an alternative? (apart from unique id)
see i was thinknig something along the lines of:
$index = $row['id'];
$_results = mysql_query("select * from complaints where complaintnumber = '$_GET[id]')
if (mysql_num_rows($result) >1 )
{
$summary = $row['description'];
$str = substr ($summary, 0, 10);
then maybe something like:
$index = $index && $str
then a re- search using this criteria.
}
Originally posted by moondance
you reckon theres an alternative? (apart from unique id)Not unless there is something else unique to each record that you could use...
moondance
09-19-2003, 10:25 AM
no there isn't
:(
moondance
09-19-2003, 11:28 AM
ok, how can i pass two arguments -
you know the code:
echo "<a href = detailed.php?id = $index>" . $row ["problemSummary"] . "</a>";
how can i pass two variables to detailed.php?
say i want to pass the id and the date:
<a href = detailed.php?id = $index,?x = $date>
and it isn't working.
edit: i want to include in mysql two parameters for the search, so i want to have a query like:
mysql_query ("select * from complaints where complaintnumber = '$_GET[id]' and datereceieved = '$GET_[date]' ")
but ican't seem to pass the date to the second page.
Thanks for any help.
Like this:
<a href="detailed.php?one=something&two=something">
Also, it's $_GET, not $GET_