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
Suppose i have an array which contains 500 names and there mobile number...
Eg -
$ar=array("98738383839"=>"name1","4343243332233"=>"name2")
Now what i want to do is give a list of 4-5 people with radio button for the user to select 1... It can me starting 4-5 peoples from the array..
Now i want to give the a search box where they can start writing name and the list of 4-5 friends with radio button changes according to that only...
For example
I would recommend you look at angular as it is much easier than jQuery. I am currently doing a project in angular, and here is how I would approach it.
Go to: http://angularjs.org, then scroll down and look at example 3. The search is very powerful and easy to implement. Implement a simple type ahead in angular, which searches the array as user type.
For the boxes with radio button, it can be easily done in angular since it allows bidirectional data binding, which means if u change a value in JavaScript variable it would also change in HTML.
Basic introduction
For your text box include something like this in HTML. This will look for an array called itemLists (you will need to define as $scope.itemLists in your controller).
<input type="text" ng-model="searchRecord" placeholder="Enter to search..." typeahead="itemList.item_id as itemList.name for itemList in itemLists | filter:$viewValue">
Then you need a http request that looks something like the following. The PHP file will query mysql and return a set a results.
$http.get("someFile.php").success(function(response) {
if(response){# store results into itemLists array}
});
Then for the boxes, you create soemthing using CSS + or bootstrap either way, get it to look how you want it to look. Then for images, Email and radio button. Use ng-model just HTML input textbox in the html example code above.
<input type="radio" ng-model="radioButton1">
<input type="radio" ng-model="radioButton2">
...
ng-model is a bidirectional binding variable, you can access it both from HTML and JS. The value is instantly updated no matter where you change it.
Hope it helps, if you need more information the angular site is always a good place to start.
Related
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.
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 8 years ago.
Improve this question
Similar to how you create a post in wordpress or even ask a question on this very website.
I want to know how to create a page by just filling out a form?
Here's what I know:
-I know how to make an html form
-I know how to place data in a database and take it out
-I know some php
What I don't know is how to to tie all of these things together. Please be as specific as possible and if you know of a tutorial on how to do this or you have the time to make a small example I would be very very grateful.
Thank you in advance for your time :-)
EDIT: To provide more details
I want to send data from a form (even a few text inputs would be enough) and for them to be placed in a page where I can display them.
And also that page should have an unique identifier so it gets stored similar to the questions on stack overflow where there is www.stackoverflow.com/posts/'identifiernumber'
And I would always to go back to that information provided I access the link which I assumed will be stored in the database.
Wordpress uses wysiwyg this is used to convert normal text into html code you can find jquery plugins for it.After user has entered the content of the page and hits submit. Wordpress directly stores the content in the database in HTML FORMAT . Now all it does is echo out the content stored in the database.
Now for the identifier , it should point out to the primary key of the database row where the content is stored. Wordpress stores a unique url as the identifier like the questions you asked is How to create a page using a form? php/html it will store it as how-to-create-a-page-using-a-form-php-html . This is then put in the href attribute of <a> tag , on click of this unique identifier it echo out the content of that row.
All you have to do now is make a form and textarea , apply the wysiwyg plugin on the textarea . Then onsubmit store the data in the database and also creating a unique identifier for it.
You question now is how to pass the identifier in the URL?
First you must know how to pass a variable in the URL and then capture it in the required place eg : www.yourwebsite.com?identifier=something and to make this a link on you website
Something
Once you have mastered this you can then study a concept called MOD REWRITE and in layman term for this is called clean URL or SEO URL . There are many blogs and methods of achieving this goal. You can google MOD REWRITE and SEO URL.
Create your website theme
on first page create form like you want
concept is like registration form and second page is edit profile
now what you stored in database from registration form
now echo in your edit profile form
for example username in database can be viewed in edit profile form
select * FROM registrationtable WHERE userid='$userid'
then store values in variables like for example
while ($query = mysql_fetch_array($request))
{
$username = $query['username'];
}
<input type="text" name="username" value="<?php echo $username; ?>"/>
p.s dont use mysql better options are mysqli and PDO
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 9 years ago.
Improve this question
I have a simple page that shows 4 different divs, all with a <h1> title (or other tag that shows text) and a form (with 1 input text) and a submit button... so far so good.
My answer is simple: I am looking for a way that:
when the user inserts a text and submit the form, the <h1> title shows the text that the user wrote
the form disappear (or takes style display:none)
this will take effect even if I refresh the page or view page in a different computer (probably need to save the data in a DB)
restart this process from the beginning (even if I need to code again).
This is for a mini game to provide to users 4 different choices and, if the user A select option 1, the <h1> will show text something like "User A was the first to choose this option. Please select a blank option" and, after the 1st raw over (point 4 described above), restart all forms.
NOTE: I am not asking in the way to "please do the code for me". I also searching for a way to store data in <php ?> - finding redbeanphp project.
I am also a newbie in SQL (just started to study SQLi last month to android development). My question is ONLY to looking for the best way to do this and what I need.
This would be the workflow:
When you click a button to submit the form JavaScript will send the form data to the server as an AJAX request and wait for a response from the server.
The PHP code on the server will read the data from the AJAX request and save it in a database and echo a success response along with the text to display.
Your JavaScript will receive this success message and hide form from the DOM and display the text in the header.
If you want the data to persist on the page on reload then you can save a flag in PHP session. Sessions persist in until you close browser window.
4.1 Use another AJAX call remove the flag from the session and reload the content.
So, if you are good with HTML and CSS you need:
JavaScript, AJAX, a JavaScript library to make things easier such as JQuery.
A server side language such as PHP.
A database to persist data. There are many choices. I am going to recommend MySQL just because there so many tutorials for it out there.
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 9 years ago.
Improve this question
I have a very simple site (PHP) that allows user changes (via jQuery) that modify elements' classes, and add/delete rows from a table.
I want to write these changes to the actual PHP file in question on the server every time a user makes a change, so that when the page is refreshed or revisited, the changes remain intact.
What's the simplest / best way to accomplish this? Thank you!
For addition/deletion of rows, fire ajax call and update records associated with the user. This is in addition to client-side (jQuery/JavaScript) changes to page. Whenever they revisit/refresh the page, data will be fetched from db, and as such will always be latest.
When you say that users modify elements' classes, I assume you mean their page's looks and styling (like some sites have on-page options to change background color, font-sizes). If that is the case, I suggest you:
Create a list of all possible states and store them in a new table in db, say display_options. You could store details like option_type (e.g. background color, font-size etc) and option_back_value (e.g. #FFF, #000 etc).
Create a new table say user_display_options where you store things like user_id, option_type and their chosen option_id.
While loading page, do a join on these tables using user_id. Then while creating your page, conditionally add classes etc to the page.
When user edits page, fire ajax call sending required data like user_id, option_type, option_id. As mentioned for other task, these changes to db will be in addition to client-side changes.
Also read #David 's comment to your question - it clears an important concept.
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 4 months ago.
Improve this question
I doubt I'm using the correct vocabulary (or tags) to explain what I'm looking for, but bear with me:
Eventually part of my page will have a section where things like list items and table data(<td>) can be entered/changed by logged in users. Let's say this is one of the <li>'s:
<!--template-->
<li><a title=""href=""><span></span></a></li>
So far my understanding is that if these entries are generated by a UI somewhere (à la Wordpress) these entries need(?) to be written in a database before becoming the generated page. Another thing I'm realizing is that the user of these CMS's doesn't automatically 'get' a copy of the generated page as source code.
What I would like to know is if it would be possible for me to make changes in HTML to this generated record/list inside notepad (I'll likely be messing with some other part of the page) and somehow have the site detect/record any changes as if they were entered through the UI?
Have PHP code create a file of the generated page
Have that page scanned for certain patterns/templates
Add the values found within the template to the DB, repeat
What language/approach could scan text and make database entries from its findings like how I'm describing? I just discovered sscanf(), but have no idea how to use it yet. I realize it's stupid to not just use the CMS, but the self-referential and text-scanning quality of it also interests me.
It sounds to me like you can implement a jQuery "Edit in Place" plug-in with a php script handler. I did something exactly this and their plug-in does all the heavy lifting, all you have to do is feed out the raw HTML with various clues about the table structure.
See this SO q/a... I used it to generate pages that displayed orders. Via editing in place, I made the orders (click-to-edit)-able. In the code, put everything in a foreach loop, then the jQuery links elements to the database through attributes like <tr id="<? echo $database_ID ?>"> to tie a row to a record and each <td> might have the database's column name as ID or a class name.
Let me preface this answer by saying it's almost certainly a bad idea, only tangentially relates to PHP, and creates at least as many problems as it solves. In particular, the security loopholes are terrible. But recently I saw an HTML form on a government website that reinvigorated my sense of humour about "lateral thinking", so just call me Pandora.
Theoretically you could implement something like this with a bit of Javascript and a cross-domain <form> post. In a nutshell, you would:
Create an HTML template with all of the tables, lists and other structures you require, plus a <form> containing a hidden input and a submit button. This template would be populated with data by the server application when the user initially requests a particular record.
Create a script for the template that parses the tables and lists for values (say, with DOM methods), serializes them (eg, into a JSON string), and sets the value of the form's hidden input to the serialized data.
Set the form's action attribute to a PHP script designed to deserialize the form data and persist it to a database. Also assign an event handler on the submit button that executes the serializer script before the form is posted.
Now, the trick here is in the user sequence. The user requests some record, which the server returns in a populated template. Ordinarily, a user would work with whatever CMS-style fields the template provides, but expiredninja instead saves the HTML source of the page, makes changes to the designated tables and lists, opens the modified HTML file in a browser, and clicks submit. The script serializes the data and the client posts the form to the server, which deserializes and saves the data.