This is kinda confusing, so forgive me if you don't understand what I am asking. I'm trying to develop my skills and I wanted to move onto images as a next step. I did a bit of searching and I thought a good way to try this would maybe be to generate military ribbon racks depending on the options the user selects.
(See something like this as an example: http://www.ribbon-rack-builder.com/ribbons/build/4)
Now, from looking at the source code I can see that the creator of that website creates a form with all of the different ribbons and allows the user to select the ones they want with checkboxes. This form is then posted to some PHP on the page somewhere.
Being new to the image concept I have no idea what kind of PHP this would be. Could anyone give me an idea of how this website could do this and where I should start should I want to create something similar?
Thanks very much!
First, you'll need to get which checkboxes were checked:
Set the name in the form to check_list[] and you will be able to
access all the checkboxes as an array($_POST['check_list'][])
Second, you'll most likely want to use the GD and Image Functions built into PHP.
There is a lot there, and it can be confusing, so I suggest you do some reading through questions on SO on the subject: https://stackoverflow.com/search?q=merge+image+[php]
Related
The title may explain the gist of it, but I want to know something. I am new to coding in PHP, and am adding it alongside my HTML5 so I can create a website for a game I'm creating. But, I need to know if I can permanently and dynamically change the contents of a file within an FTP.
So, say if I had 2 array values in a Username and Password field when I first created it. Is there any possible way to create a function that, upon registering information, allows me to permanently add those array values, so that every time I open the file, it stays at three values?
I want to do this so that I have a simple login system created. If there are any questions that have what I'm looking for in PHP, feel free to close as a duplicate and point me in the right direction. This is my first step, and I hope I can get some help on it. Thanks again in advance.
Okay. So I don't have any example code to show, but after doing a bit of research and learning the basics of PHP, I think the answer to my question should be pretty simple.
Here is the scenario, as I would like it to be:
On the homepage there will be several team names, with scores next to them. Like "house-points" in Harry Potter.
Below the score is a small text-field. Below that is a submit button.
The user will put a number in the text-field, press submit, and that number will be added to the team's total score.
NOW. I know how to achieve all of that with JavaScript. Easy. What I want to know IS:
How do I make that new number (the new score total) STAY there. I need to permanently alter the HTML when that submit button is pressed.
All I know is that I need to use PHP. I know the basics of PHP, so whatever the answer is, just throw it at me and I'll figure it out.
Sounds like what you want to do is submitting forms. First drop the JavaScript, you won't need it. What you need is to put your text fields in a form and when you submit you can fetch your values with $_<GET|POST|REQUEST>['<name_of_field>'].
Then you will need to store it somehow. The best way to do it is to use a database like MySQL or MongoDB to store it, but it could be a bit tricky if you are just learning this, so maybe you would like to stick to files. You could do this with INI files and PHP's INI functions.
Lastly you will need to print out the correct values to the website. Now this is easy: Just edit your HTML file to do something like
<?php echo $score['team1']; ?>
for each team after retrieving the correct values at the top or something. (Don't forget to rename the HTML file to .php as well).
Now you should be all set to save your scores. =)
If you mean really permanent you'll have to send it to a database via Ajax (combination of PHP and Javascript). OR write it to a text-document, which is less good.
I want to make Newegg's like catalouge functionality for my little website. I want mine to be sligthly different(greatly simplified) though. I haven't done anything so advanced(atleast in my books) before, and wanted to know if it's possible to do. I want to use PHP and JS. The new records will be added manually through using either phpMyAdmin or pehaps I will install and use either SQLyog, HeidiSQL or Navicat for such purposes. Could someone point me to the right resources to get this kind of job done as fast as possible and properly?
What I had in mind was:
For example the cell which contains the thumbimage, all the mini information about the product and the big price tag will not have a separate, more detailed page. Everything user will need to know will be inside that product cell.
Right under the thumbnail image there will be numbers(1 2 3 4 5 6), and when you hover over them, under the cursor, a big version of one of the all available images will appear.
Lastly, it should have the page generation(don't know what you call it). For example there's more than 20 product entries on the page, then the server should create a new page(First 1 >2< Last) to hold the older records.
Oh and there won't be any shopping cart functionality. You can't really "order" these kinds of products, you just find something you like and call me up about it.
TIA
I'm sure there are dozens of books on this subject. I'm attempting a short reply, however:
This sounds like something that could profit from:
a MCV-framework like CakePHP (or Django, Ruby on Rails etc), which could handle database-logic (including pagination, which is the word you're looking for), and
a JavaScript library like JQuery to handle Ajax, JavaScript and other UI-related stuff.
++?
For the page numbers, I recently had to do this. The technique is called pagination, and this thread helped me out immensely: PHP Formula For a Series of Numbers (Mathy Problem)
The thumbnail effect you want to include would need to be done in javascript. I'd recommend learning jQuery, as it is pretty easy to use for this sort of thing.
This is a hard question to answer because you haven't given much indication as to your skill level, or progress towards accomplishing your goal. Assuming we're starting at 0, there is probably more to discuss than this thread can contain. :\
UPDATE
To learn PHP's database functions, I would lean on W3School's PHP/MySQL tutorial for a quick summary, referring to the php manual's mysql documentation for details and code examples when W3schools isn't enough. This should at least get you the markup you will need to work with.
For the thumbnails, I would reiterate my recommendation for jQuery, specifically attaching a .hover() event to the image numbers (this is equivalent to the onmouseover and onmouseout events in JS) that uses the .fadeIn() and .fadeOut() animations to show and hide your full size images. Hope that helps.
So I've been struggling with finding a simple and efficient solution for the following problem. The solution I have now works, but since I'm working on this for the sake of learning ...
So, the case:
I have a PHP page which gets loads of persons from a DB, then sorts them and finally puts all persons
in a html list. What I'm after is a elegant solution to edit these persons by clicking on them from the list. I've found a jQuery pop-up solution that looks brilliant, but not so easy to use for beginners.
Since there are several persons I need to produce a different pop-up window depending
on which person is clicked. The problem is that the jQuery pop-up is based on the html being pre made, which is obviously hard since I don't know which person the user will click.
The best I've come up with so far is sending a GET -variable to the page with the person list, which then checks if there is a valid variable from GET and produces the HTML for the clicked person based on the id/variable. The problem with this is that I have to essentially run the same query twice; once to get all persons and once to get the clicked person. It isn't a big problem, it's more that since I'm new with jQuery I'm wondering if there is a simpler/better solution. I'm not really sure what jQuery can and can't do.
Thanks for any replies.
I'd start by asking why you don't ask the database to sort/ORDER the values before sending them back to your PHP page? It's well-suited for that sort of thing.
You could know which person was clicked if you added the database id to each element and passed that around. Have jQuery add it to the DOM element for each row in the HTML table.
kinda the standard way would be to pass the persons as JSON, and use the jquery templating system to build the forms. Of course this could be a bit daunting to a beginner, but its not that hard.
I'm trying to think of a way to create a list of items that I can display on a webpage that my visitors can tick off, without ever having to log in.
The list may be like so:
[ ] Buy potatoes
[ ] Pickup kids
[x] Drink more water
[ ] Go for a Run
If User A visits the site, and clicks "Drink More Water" I want that to save in a database so that when User B visits, "Drink More Water" is already ticked.
Is there any simple ways to do that:
in PHP?
with Javascript?
or even as a WordPress plugin?
Do you know if there's any existing code around that does this?
TaDa List by 37Signals comes very close, but only allows specific people to tick things off.
Any suggestions would be greatly appreciated.
Thanks
Turgs
If you want to create this yourself you should learn PHP and MySQL (and possibly Javascript (for AJAX)), and HTML and CSS (maybe you already know some of these). After you know these it will become clear how to create this.
You should first learn HTML
then PHP
then MySQL (or any SQL that works with PHP)
then CSS
Then Javascript
We can't really answer your question like this, because it involves big amounts of code. Adn won't really help you if you don't know these languages.
I'll tell you what you need to do, but you're going to have to research most of the things.
You need html to create the list.
You need php to query sql and check if one of them should be checked or not.
Load the page with the data you got from your database server (set the checked ones as checked).
When the user checks one of them you need to store it in the database, so that when another user loads the page he can then get the changes from the database.
Hope this is clear enough.
Just store that information in cookies.
$_COOKIE['ticket'] = 3;
when he visit the page next time just check if $_COOKIE['ticket'] is not empty.
You could do this kind of thing with a file instead of a database. So when the user checks off a box, it loads a PHP file that reads an XML file with the tasks and check-status, then re-writes that file with the modified value.
It's quick, dirty, and doesn't need a database.
You could use a REST like url that defines a list. i.e.: http://ticklist.com/list/145
People can share this common list.
Something like the logic of http://friendpaste.comTo let people share and edit source codes.