By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,158 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

new page after result page like "thescripts"

P: 13
Hey people..

I'm trying to find out how i can click on a result page after a search, so it can show the result more detailed in new a page.

Is this possible?

All the user datas is stored in a mysql table..
So do i have to send theese datas into separates html/php pages, before the users can search after it?

The idea is much like "thescripts" page..where you serach first and then you can click on the link to read the question and comments..

Any idea or code help?
Skuer
Feb 10 '08 #1
Share this Question
Share on Google+
5 Replies


MarkoKlacar
Expert 100+
P: 296
Hi,

What you need to do is keep track of what thread a particular entry is for and all you threads, using an id is probably the most common.

After this you can display the thread information and provide the user with a link that will get all the entries with the same id as the thread.

Hope I'm clear enough, if not let me know.

Good luck
Feb 11 '08 #2

P: 13
Hi,

What you need to do is keep track of what thread a particular entry is for and all you threads, using an id is probably the most common.

After this you can display the thread information and provide the user with a link that will get all the entries with the same id as the thread.

Hope I'm clear enough, if not let me know.

Good luck
Hey..

I tried to understand this after reading it several times, but i still don't get it:S

If You're talking about threads like there are in a forum, i don't got that on my page.
Would it be bether to automaticly make different html/php pages after the submit from the user, that contains the data from the table?

Skuer..
Feb 11 '08 #3

ronverdonk
Expert 2.5K+
P: 4,258
Basically, you search your table for the search items entered by the user. For each result you display a link on the screen. That link contains the identifier of the full result (or entry) to be shown. When clicked you are passed that identifier, that you can use to read the full data result and display it.

A simple program like the following shows this.
[php]
// Search.php
// Search through the table and display each result in a link
$sql = "SELECT answerid, question FROM questions ".
" WHERE question REGEXP '$searchword1'".
" OR question REGEXP '$searchword2'".
" ORDER BY question";
$result=mysql_query($sql) or die("SELECT error: " . mysql_error());
while ($row=mysql_fetch_assoc($result)) {
echo '<a href="display.php?id='.$row['answerid'].'>'.$row['question'].'</a>';
}

// Display.php
// Called with the answerid in the $_GET array
$id = $_GET['id'];
$result=mysql_query("SELECT answer FROM answers WHERE id=$id");
while ($row=mysql_fetch_assoc($result)) {
echo $row['answer'];
}
[/php]
Drop by when you have more questions.

Ronald
Feb 11 '08 #4

P: 13
Basically, you search your table for the search items entered by the user. For each result you display a link on the screen. That link contains the identifier of the full result (or entry) to be shown. When clicked you are passed that identifier, that you can use to read the full data result and display it.

A simple program like the following shows this.
[php]
// Search.php
// Search through the table and display each result in a link
$sql = "SELECT answerid, question FROM questions ".
" WHERE question REGEXP '$searchword1'".
" OR question REGEXP '$searchword2'".
" ORDER BY question";
$result=mysql_query($sql) or die("SELECT error: " . mysql_error());
while ($row=mysql_fetch_assoc($result)) {
echo '<a href="display.php?id='.$row['answerid'].'>'.$row['question'].'</a>';
}

// Display.php
// Called with the answerid in the $_GET array
$id = $_GET['id'];
$result=mysql_query("SELECT answer FROM answers WHERE id=$id");
while ($row=mysql_fetch_assoc($result)) {
echo $row['answer'];
}
[/php]
Drop by when you have more questions.

Ronald
Wow..

Thank you very much, will try it as soon as possible

But just a quick question, so i don't just copy it, but also learning it..

What's the data in "answerid" and why are you using the " $_GET['id'] " when you're displaying it?


Many thanks
Skuer
Feb 11 '08 #5

ronverdonk
Expert 2.5K+
P: 4,258
Column answerid? I don't know, it is just an example of how to relate a question in a questions table to an answer to that question in an answers table. This is not a real application, just an example of how you can solve your problem.

I am afraid you miss some basic knowledge about PHP programming. When you do not know what the $_GET (or $_POST or $_SESSION or $_GLOBALS or $_REQUEST) is, you'd better get some basic education on how scripts can communicate with each other or how they can pass data to each other.

Ronald
Feb 11 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.