tomas.hortlax Posted March 5, 2010 Share Posted March 5, 2010 HiPlease forgive me. I'm new in this. This problem I have may be very easy to resolve.But I can't. And forgive my bad english. I have a big databas with many different values. Both text and figures.I have made a display site with the main values. But I want that my userswould be able too look at many more values if they want.When I display each databas name I want the possibility too link it furtherin a new window there all the values is displayed.Like thisA,B,C,DAB, 1, 1, 20CD, 1, 2, 50EF, 2, 1, 30My page is displayingAB 1 1CD 1 2EF 2 1If the user clicks on AB a new window will open and display AB 1 1 20/ThanksTomas Link to comment Share on other sites More sharing options...
justsomeguy Posted March 5, 2010 Share Posted March 5, 2010 You need to have a column that is unique for every row. If your A column is unique, then you can use that. You put the unique value in the URL, and then get it on the other page to look up the information in the database. e.g.:<a href="details.php?id=AB">On details.php you would check $_GET['id'] to see the value that was passed, and use that to look up the rest of the data. Link to comment Share on other sites More sharing options...
tomas.hortlax Posted March 6, 2010 Author Share Posted March 6, 2010 You need to have a column that is unique for every row. If your A column is unique, then you can use that. You put the unique value in the URL, and then get it on the other page to look up the information in the database. e.g.:<a href="details.php?id=AB">On details.php you would check $_GET['id'] to see the value that was passed, and use that to look up the rest of the data.OK I think I understand that. I have a unique column for every row (but for now the site dont check it. I will fix it later).But there will be ( I hope) very many unique rows. How do I fix the id=AB (<a href="details.php?id=AB">) when I dont know what the user is naming his row.This is maybe HTML issue also? Thanks for all help. Great site!!! Link to comment Share on other sites More sharing options...
justsomeguy Posted March 8, 2010 Share Posted March 8, 2010 You need to print that link from the data in the database. That's what the link will end up looking like, but you'll use PHP to write that link based on whatever data you find in the database. Link to comment Share on other sites More sharing options...
tomas.hortlax Posted March 9, 2010 Author Share Posted March 9, 2010 You need to print that link from the data in the database. That's what the link will end up looking like, but you'll use PHP to write that link based on whatever data you find in the database.OK I think I understand.But must I take the value from column A and put in a variable? And change AB in <a href="details.php?id=AB"> to that variable?/Tomas Link to comment Share on other sites More sharing options...
justsomeguy Posted March 9, 2010 Share Posted March 9, 2010 Right. Link to comment Share on other sites More sharing options...
tomas.hortlax Posted March 9, 2010 Author Share Posted March 9, 2010 Problems!I cant fix it. What am I doing wrong?I have made details.php like this<?phpecho $_GET['id']; ?>Just to check the function.And like this... $result = mysql_query("SELECT * FROM databas WHERE no=$i AND no_total=$max_3"); $row = mysql_fetch_array($result); $name=$row['A']; echo "<tr>"; echo "<td>"; ?> <a href="display_serie.php?id="> <?php echo $nameDoes it work? NoWhat am I doing wrong? Link to comment Share on other sites More sharing options...
justsomeguy Posted March 9, 2010 Share Posted March 9, 2010 <a href="display_serie.php?id=<?php echo $name; ?>"> Link to comment Share on other sites More sharing options...
tomas.hortlax Posted March 9, 2010 Author Share Posted March 9, 2010 <a href="display_serie.php?id=<?php echo $name; ?>">Thanks!!! Link to comment Share on other sites More sharing options...
tomas.hortlax Posted March 10, 2010 Author Share Posted March 10, 2010 OKYes I know... this is easy...but not for meIf I also want to print $i, like something like this<?phpecho $_GET['id'];echo $i?>How to transport a value with a varable to details.php ? Link to comment Share on other sites More sharing options...
justsomeguy Posted March 10, 2010 Share Posted March 10, 2010 The 4 ways of sending data between PHP pages are these:1. The querystring, available in $_GET2. Through a form, available in $_POST3. Through a cookie, available in $_COOKIE4. Using the session, available in $_SESSIONSo you can either print your values into the URL, and access them in $_GET, or you can build a form and submit the form, then access the values from the form in $_POST, or you can save the values in a cookie using setcookie and then access them on the other page in the $_COOKIE array, or you can use the session. So, using the URL is usually the way to go if they click on a link to get to the other page, or you could use the form if they're submitting one, cookies are generally used only for tracking logins or where people go on the site, and sessions are used for pretty much all other temporary storage. You can start a session in PHP, save whatever you want in the session, and all of those values will be available on any other page where you use the session. Check the PHP tutorial on the site, there's a section about sessions. Link to comment Share on other sites More sharing options...
tomas.hortlax Posted March 10, 2010 Author Share Posted March 10, 2010 The 4 ways of sending data between PHP pages are these:1. The querystring, available in $_GET2. Through a form, available in $_POST3. Through a cookie, available in $_COOKIE4. Using the session, available in $_SESSIONSo you can either print your values into the URL, and access them in $_GET, or you can build a form and submit the form, then access the values from the form in $_POST, or you can save the values in a cookie using setcookie and then access them on the other page in the $_COOKIE array, or you can use the session. So, using the URL is usually the way to go if they click on a link to get to the other page, or you could use the form if they're submitting one, cookies are generally used only for tracking logins or where people go on the site, and sessions are used for pretty much all other temporary storage. You can start a session in PHP, save whatever you want in the session, and all of those values will be available on any other page where you use the session. Check the PHP tutorial on the site, there's a section about sessions.When I are new in this subject. I will do as the master says. And how would you do?I have fixed that the user can click on the databasname. And now I want to show the user all of the data in the databas.The databas is like a serie 1,2,3,4,5,etc and each serie can have a sub serie 1,2,3,4,5,etcThe first page only show serie 1,2,3,4,5 etc with the highets sub serie. When the user is clicking on the name of his seriehe want to see all data recorded in that serie with all of the subseries.I must have at least two variables with me in the new .php file. And open the databas in this file.Or ?/Tomas Link to comment Share on other sites More sharing options...
justsomeguy Posted March 10, 2010 Share Posted March 10, 2010 Yeah, you need to include the ID or whatever of each series. It sounds like it's easiest to use the URL for your situation. You'll also need to keep passing the same values along. So if they click on a certain name, and then it goes to a page that shows the series, then the links to show the subseries also need to include the name they clicked on in addition to the series ID. Link to comment Share on other sites More sharing options...
tomas.hortlax Posted March 10, 2010 Author Share Posted March 10, 2010 Yeah, you need to include the ID or whatever of each series. It sounds like it's easiest to use the URL for your situation. You'll also need to keep passing the same values along. So if they click on a certain name, and then it goes to a page that shows the series, then the links to show the subseries also need to include the name they clicked on in addition to the series ID.Can ID be an array? Link to comment Share on other sites More sharing options...
justsomeguy Posted March 10, 2010 Share Posted March 10, 2010 You can have an array of IDs. Link to comment Share on other sites More sharing options...
tomas.hortlax Posted March 11, 2010 Author Share Posted March 11, 2010 You can have an array of IDs.Now I do not understand. This is too advanced for me.I have a couple of variables that I want to follow the user everywhere.Think it will be 4-5 variables that must always follow the user regardlesswhich site he lands on.Are gone make a array or have five different variables?/Tomas Link to comment Share on other sites More sharing options...
justsomeguy Posted March 11, 2010 Share Posted March 11, 2010 If you want to track certain information regardless of where they go, you might want to use the session to do that. http://www.w3schools.com/php/php_sessions.aspYou might want to go over the sections about arrays and PHP in general if you haven't read them yet, you need to understand that stuff. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.