Thauwa Posted April 3, 2009 Share Posted April 3, 2009 I have a table called 'items' and it has fields called name, cost and description. When dynamically echoing out the values (ex: items.php), i have added an extra field called URL, which is a URL for ex: page.php?item=table Now, I get the URL by using the variables, but how do I design page.php, so as to display each record regarding 'table', i.e. name, description and cost. The thing is that I need to display them individually. And another thing that I want to know is how to paginate the records in 'items.php' (the example I used at first). Thanks in advance for any help that you can offer. Link to comment https://forums.phpfreaks.com/topic/152349-echoing-out-data-individually/ Share on other sites More sharing options...
PHP Monkeh Posted April 3, 2009 Share Posted April 3, 2009 If you want to display the variables on page.php (passed via the URL), you use what's called $_GET. For example: echo $_GET['name']; echo $_GET['cost']; This is if you've called the page using a URL such as: page.php?name=Example&cost=10 Link to comment https://forums.phpfreaks.com/topic/152349-echoing-out-data-individually/#findComment-800150 Share on other sites More sharing options...
Thauwa Posted April 3, 2009 Author Share Posted April 3, 2009 That means that I have to include all other variables in the URL? Link to comment https://forums.phpfreaks.com/topic/152349-echoing-out-data-individually/#findComment-800179 Share on other sites More sharing options...
PHP Monkeh Posted April 3, 2009 Share Posted April 3, 2009 Well it depends how you want to structure it and what the page is going to do with the variables. Common practice is to pass the ID of the row in the table via the URL, and then on the receiving page use that ID to query the database. Say we make this the URL: page.php?id=3 Then on page.php have something like: $query = "SELECT * FROM `table` WHERE `id` = '" . mysql_real_escape_string($_GET['id']) . "'"; Using the URL to pass a unique identifier and then using that to retrieve the information you need from the table is common practice. Link to comment https://forums.phpfreaks.com/topic/152349-echoing-out-data-individually/#findComment-800186 Share on other sites More sharing options...
Thauwa Posted April 3, 2009 Author Share Posted April 3, 2009 OK! Lemme try it now! Now, do you happen to know about pagination? Link to comment https://forums.phpfreaks.com/topic/152349-echoing-out-data-individually/#findComment-800188 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.