Codeigniter linking pages to each other [closed] - php

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
This may be a bit confusing to you but I'll try to make it as simple as possible.
I am working on a simple project where I have only one type of content coming from my database. When a user lands on my website they will be seeing one of random entries as home page view and then they will be able to click on next and previous to see other available pages.
It may work like pagination, but the difference is that pagination pulls all entries from database and lists them based on number of listing per page. My approach is the exact article page to have only next article and previous article links on every page.
Would you please let me know how would you approach this if it was your application? I'm looking forward to hearing your thoughts.
Thank you.

you have to build a query which returns max three rows - one for prev data, one for current data and another one for next data.
Now you have to check if prev data not found in the query result then do not show prev link in the page
Also you have to check if next data not found in the query result then do not show next link in the page.
Query for first page will return two rows and for next page onwards will return three rows. for last page query will return two rows.
Depending on the which links getting clicked you have to build the query.
For first page you return the query with first and next records from the db. from next page onwards you have to get the clicked link's id and determine the prev and next data for next page onwards.

Related

How to link/navigate through SQL search results in PHP one page at a time

I am building an admin type script to view records within a mySQL database. This links in numerous tables and is all working perfect. I have now added a filter form to allow me to search/filter for records that match specific criteria. Again this works perfect.
The problem I cannot get my head around is this...
For each record I have a link that allows me to go into that record and view more information/perform tasks on the record.
Initially it was simple to have a 'Previous' and 'Next' link for cycling through the records which meant I didnt need to go Back to the search results to go to the previous/next record. It simply +1 or -1 from the current record ID to generate the link.
Now however I am filtering so the records ID's might be 1,3,4,5,8,10,15,30 etc
The problem is now that once I click into any one of the results to view that record I essentially lose the filtering and all of the results.
The only way I can think of achieving this is to pass the filter variables in with the link and redo the filtering every time the View page is loaded, working out where the current record is in the result set and creating a link based on the previous and next records in the result set.
Am I doing this correct or is there a better way?
I have searched but most answers are geared towards the basics of looping through mySQL query results which sounds the same but is very different.
Any advice would be greatlt appreciated!

How to dynamic generate pages in php? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm doing a web app with PHP in which users have different number of tabs in the menu depending on a certain number of things, one user can have one tab in the menu where another user has ten.
I've managed to dynamically generate the menu items but now I don't know how to create files (pages) where the user gets redirected once he presses on any of the menu tabs.
All these files look the same the only thing that changes are the text, just some strings.
Summing up, what I want to do is:
Generate and destroy files automatically when the user has to consult something
How to link the menu tabs (href) to them automatically
The best would be to use a PHP page as template you could call it.
Lets say for example a user is logged in and clicks the view data page (data.php)
on your link you could have something like this:
and in data.php:
<?php
$USER_ID = htmlspecialchars($_GET["id"])
//SQL Request to get user priviledge and authentificate
//OR
//Check the cookie session for information
if (user_priviledge == 0)
{
//
//Show only data for 0 users
//
}elseif (user_priviledge == 1) {
//
//Show only data for 1 users
//
}
?>
This may not be the solution you wanted but your question wasn't very clear either so if you need any other information make sure to bring more precision.
The condition which are using for tab use same condition to show page. But add that condition in your text.Because your text is changing not page I think.
I this this might help you.
since all files will look the same and only variables will change, you can create one php file and just send the necessary data when a user clicks on the tab to assign to the variables in that page. You do not need to keep on creating custom pages for each and every tab.
Provide some code which you have written for this so that we can help you further

codeigniter search box and keeping data

I want to keep page in search form and when I visit another page and return to previous to see only what I search.
For example, I have page with table, in that table I have list of all products which is 30 products. When I submit search query for some word and get per instance 5 products, I want to keep that and visit all another pages and when I back on product page to see again only that 5 products.
Any help?
You're looking for a way to store dynamic data. Your best bet would be to use something like Sessions or LocalStorage

PHP - how to generate a URL on save like JSFiddle does? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm trying to recreate something you might know from imgur or jsfiddle - you just type something or upload images, then you click "save" or "upload" and then you get a original link in form of imgur.com/smth or jsfiddle.net/smth. How is this done? I've created simple website where I can write notes and save them and it works perfectly well for myself, but I wanted to share it with some of my friends and I have absolutely no idea how can the "save" button attach their changes to new URL every time they press it? I know this is pretty basic but I couldn't find anything on the matter online and I really have no idea how to handle this issue, excepting I'll be writing their changes to different SQL rows.
Thanks for any clues :)
If you're trying to create something and let people edit it and keep the same link you could do it with PHP and mySQL.
I think the easiest way would be to have one page to create the initial note and one to update/view it. Once you create it the save button would add it to a database with a unique id of some kind like an auto increment number. To send the page you would use a link like www.somepage.com/info.php?id=1. The "id=1" part would be the unique id within the database. In info.php, you would need to use $get_["id"] and set that to equal the database id row and load the info from there. Then you could allow edits to that row from that page. You would have to set the save button to update the row.
To get something like somepage.com/smith, if you're on a linux server, you would use htaccess and mod_rewrite.
This is a really down and dirty gist of how you could do this, but it should send you in the right direction.

How to determine the last row of the print area in PHPExcel?

I have a large table, which does not always fit on a print page. If the table does not fit on one print page, script must write "Contunue on next page" into last row of current page. How to do it?
My guess is that you are building a page updated by javascript.
I can provide 2 answers here:
from a usability point of view, you should add "next page" both
before and after the table. By then, a user that is searching for a
specific page don't have to scroll down all the page to go to next
page
from a technical point of view, there's no reason to put the next
page inside the table. Just put it into a and just name it if
you need to access to it later on.
In case my guess wasn't correct, can you please give more detail about your problem (includig relevant code snippets)?

Categories