Generate ID card through fpdf, php and mysql - php

I want to generate ID card for the students admitted in the college.
i have linked a photo in which i am sharing as to how the i want the id cards in pdf file through php and fdpf. and i am fetching the date from mysql.
Suppose i have 13 students available for a particular course. Now, i want the data to first actually work multicolumn wise and then as the page is filled, it should create the back side of the page in next page and move on to other page. On one A4 page, i can have only six ID cards and on the next page, six backside of those id card and again this step should repeat. I am confused.

You can use the AddPage() method to simulate a page feed. To add two pages, call it twice.
There's a third-party script to use a different margin for odd and even pages, like in a book, but I don't know if you can force double-sided printing from a PDF document.

when you are trying to generate ID then what should your goal is to generate six on a page and you can do that with looping.
Because printing on backside is printer property.

Related

How to efficiently make many (100+) HTML pages with minor differences

I'm trying to make 100+ registration pages for my site with minor differences between each one.
For example:
State, Age, Start Date, Client Goal
Page 1 characteristics: California, Age 18-25, Start Date Dec 1, Goal 1
Page 2 characteristics: New York, Age 25-30, Start Date Dec 15, Goal 3
Page 3 characteristics: New Jersey, Age 18-25, Start Date Jan 1, Goal 2
Goal:
It's important that I have separate pages and not just a form or something selected by the user on a single page. Ultimately I'd like to have many more levels of customization than what I have above and would like to control all the pages without having to go in and edit each individually.
Suggested Method:
I was thinking I could make 1 PHP template and use it on every page to pull a unique code from the href to determine what data it gets from the database to display on the page.
To get my page 1 it would be something like:
window.location.href
returns -> mysite.com/CA-18-12-1-G1
Then use that code to set PHP variables which would customize the entire page just by echoing the html with the variables.
Is there a better/smarter/safer way?
I'm fairly new to this.
Think of it this way: you want to make just one page, and you want to render it with 100+ different customizations.
Figure out the common HTML and CSS for your template page, and figure out what needs to change customization-by-customization. You'll have a set of customization parameters when you finish this design work.
Then, design some kind of data structure to hold your customization parameters. A table in MySql with one column for each parameter and one row for each of your 100 customizations might be a good way to do this.
Then write a php program to retrieve the row with the parameters for the customization you want, fill in your common HTML with the customizations, and send it to the browser for your user to fill in.
If you only need two or three custom pages, my advice would be to program them separately. But with 100 you need a template / parameter approach.
For writing a single page and then using the code of that page in multiple pages you can use PHP.
Lets say you have a page named constant.phpand you want to use the code of the page in a different PHP page named home.php. You have to use this code in the home.php where you want the code to be inserted:
<?php include "constant.php";?>
Now the code ofconstant.php code will get inserted in the home.php in the place where you wrote this code.

Creating x amount of pages equal to x ID's in database?

The title may be a little vague, but I'll try to explain the concept here.
I have a site in which daily new items ( sports games ), get published, now what I would love is that my users would be able to click on a certain game and get redirected to a new page with more detailed information about that one game.
The thing is, creating every php page seperate for every game each day is a lot of work because also a lot details in the page need to be changed.
Now I was wondering if it is possible in some kind of way that there's a script that reads, OK you have 5 games today, page 1 = id number, title of the page is the matches name, extra info is the info that stands with that id.
I don't know how else to explain this so I hope this was good enough.
Thanks for your time and reading this :)
You can use requests to select the page (the best way is to use $_GET as suggested by gbestard) to select the ID. Then you can have some static content (like url or short article or link to screen shot or something similar) stored in your database under the same ID as the game, and upon clicking on the link to the game, the page is reloaded and you populate it with the new content, that was stored in the database.
You can even store entire pages with static html (as in article or short game description in your case) content and etc in your database and simply call them to populate a div.
If you have something like a custom made admin section of your site, you can add a page to edits it with a js plugin like ckeditor and the creation/editing of articles will be a piece of cake.
It's pretty much a standard case of a CMS(Content management system).

Custom post feed for iOS - current post offset

I'm trying to make some custom feed with posts of image and titles and currently I'm doing it for mobile. I'm using PHP for webservice.
When using pagination how do you download posts from web? Do you send some page parameter to webservice or is there some other way?
So something like this:
http://www.mywebpage.com/?command=stream&page=0
and then just increment page that is private variable in-app and autoincremented before every new request? Or this is done in a different way?
Thanks.
Yes you are on the right track. The usual practice is to send a currentOffset, or a page number parameter (if your entries per page is constant).
I am assuming you want to display the feed in a UITableView, and lazy-load more entries (the next page of entries) when the user scrolls to the bottom of the list. You can implement the pagination logic yourself by implementing scrollViewDidScroll: to detect that you have hit the bottom of the list, but I find NMPaginator particularly helpful for this purpose.

jQuery/PHP-MySQL News Ticker

I have been searching for a Vertical Text Slider OR Vertical News Ticker, exactly like this one:
http://www.tradekey.com/
(scrolling the latest buy/sell offers in the middle)
I found few tickers but I still can't figure out how do I make it to get data from one specific MySQL table & display them randomly.
Someone point me to right direction or provide me any link where I can found any easy to configure news ticker.
UPDATE-171212:
Well I checked the ajax folder, there are some files getting user info from db.
But it always displays the country info from the member profile, by ignoring what is mentioned in the "buying/selling lead" info.
its using $country, & its same in both member profile info table & buying/selling leads table.
What if I want it to pick from buy/sell leads, & if no country is mentioned then get country data from member profile.
For Example:
http://www.tradeglobus.com (import export trade leads in the middle)
I have to correct country info issue in this one.
Look into setInterval mixed with AJAX to update a list of the items you want to display. Then look into Jquery to add a ticker effect.
To elaborate, create a file that fetches the items from a DB. Then use an ajax request to get that list at regular intervals. From there it just takes a Jquery plugin or equivalent to display the list in ticker form

Update DB column every time a link is clicked via PHP

I have searched online for this issue, but the results are mostly based around Excel.
I have a webpage that has a list of videos. Every time someone clicks on a link, they are taken to a separate page where they can view a video. I have a table in my mysql database that links video id to views. I would like to increment the views column every time someone clicks on the link.
I know how to do this on the database side, but I am trying to figure out how to trigger the DB operation via PHP. I thought about having a script at the top of the page that calls the stored procedure to update the tally everytime the page is loaded, but the problem with this is that the video doesn't start automatic ally when the page loads. Users have to manually click on "play".
Why not write an Update query on the table which gets called everytime a link is clicked?
It is a little confusing where you want to increment the counter. You give three situations:
When a user clicks a link to a particular video's page
When a user loads a particular video's page
When a user clicks play on a video
1 & 2 wouldn't give an accurate count of those who actually watched the video, so I'll choose that you meant 3.
It depends on your video player then. If the player has a way to hook a javascript function to the start of a video, then you can use that to make an ajax request back to a server page that updates your database. If the player has no hooks then you're limited to on page load, which will be less reliable.
Does this help? If I miss understood the question, please clarify by updating the question or adding comments. PS. adding code of what you've tried goes a long away as well.

Categories