I'm using CKeditor but I'm not working out how to create the php file that stores editing textareas in MySql DB.
I'm quite newbie in php/mysql..
javascript code of CKeditor calls is:
$(’#my_div’).ckeip({
e_url: ’test.php’,
data: {
example_var : ’example_value’,
example_var2 : ’example_value2’
}
)};
What I have to write in test.php to making it store data of ckeditor in MySql?
Should I create a new table in database first ?
thanks a lot
I think the best way to handle this is create a new MYSQL table with two columns. One as an id for the textarea and then the other column to store the text. For a basic tutorial about MYSQL and PHP check out W3School http://www.w3schools.com/PHP/php_mysql_intro.asp
I am a newbie to CKEditor, too. But it seems like it would be quite easy once you get the data from the editor into a javascript variable, like:
var editorData = $('my_div').ckeditorGet().getData();
You can then put editorData into a hidden input field and then submit it to the PHP file that you're going to create. On that PHP file you would take it with something like:
$theData = $_GET["name_of_the_hidden_input_field"];
//here comes the PHP code for inserting $theData into mysql
Related
I am using CodeIgniter v 3.1.4. In one of the form, i have a text box to save urls (like https://stackoverflow.com/questions/ask, http://google.com etc.) into the MySql database.
Before save, i am sanitizing the urls like shown below:
Inside Constructor:
$this->load->helper('security');
Inside Add function:
$hlt_url = $this->security->xss_clean($this->input->post('txtHLnk'));
$hlt_hlines = $this->security->xss_clean($this->input->post('txtAreaHLine'));
When i enter simple/plain string in the textboxes, then the data gets saved in the DB, however when i enter url in the textboxes, the data is not saved in DB, neither does it show any error message.
Please explain with code whats i am doing wrong. Thanks
$hlt_url = $this->input->post('txtHLnk', true);
$hlt_hlines = $this->input->post('txtAreaHLine', true);
I thin kthis is the new implementation of sanitizing inputs in latest version.
Wizzards :)
I really want to use Quill richtext editor but I have no real knowledge of JSON or how is parses the so called "Deltas".
Basically, I need to collect the page from the editor and process it with php before storing it in the mysql database, and, from the database back to the editor if user wishes to update an existing post. It needs to be able to parse text and multiple images...
I don't have 3 months a piece to learn js/json, can anyone help me out with this one? Thank youuu!
So acording to the Quill documentation (https://quilljs.com/docs/api/) you can use var delta = quill.getContents(); to collect the data. Would it be something like this with an onclick() function? I dont even know with js if it has to be within a form? remember I don't know js :)
<script>
onclick(does this); // or can it be updated as the user creates the document?
var delta = quill.getContents();
// what then?
</script>";
The php would require a different variable if each image to be processed, perhaps in an array?
<?php
$images = array();
$images[0] = 'json/delta/quill image?';
$images[1] = 'etc...';
$images[2] = 'etc...';
$images[2] = 'wtf...';
?>
Why on earth they don't have a simple example of how to do this I don't know, its an all too common problem with these things.
I have a simple HTML form comprising of check boxes and text fields.
When I submit this form it submits the data back to the same page where I capture the data and write it to a text file.
What I'd like to try and do is write some of the check box and field data to one text file and the rest to another.
Can this be done ? if it can how do I say which fields are written to which file ?
Thanks
you send your form and after that you handle the data. For example:
$dog = $_POST["dog"];
$cat = $_POST["cat"];
$fileForDogs = fopen('path://to/first/file', 'a+'); //a+ means if not exst, create one and write on the end of file
fwrite($fileForDogs, $dog);
fclose($fileForDogs);
$fileForCats = fopen('path://to/second/file', 'a+'); //a+ means if not exst, create one and write on the end of file
fwrite($fileForCats, $cat);
fclose($fileForCats);
I would highly recommend to look at databases for example mysql to save data from form.
I have a CSV file that contains many data.
I use PHP to read and view it in WEB. I need to have a functionality like ADD, EDIT and DELETE. I already done the ADD using the a or append. I will add data in HTML Table and automatically it will add also in CSV file. I didn't use database here.
My problem now is the EDIT. What if i want to edit some data in CSV file using the HTML Table and like the ADD i want to automatically update it to my CSV file. How can i do that?
I already tried the w, w+, r+ but it didn't work. By the way I am using CODEIGNITER here.
Thank you in advance for the help.
I would keep the logic on server and do all the csv rendering eventdriven.
Here you have a good csv lib: https://github.com/goodby/csv
So the process would be something like this:
Client: Load csv preformated (via php) from server and display in html
Client: Do MVVM bindings etc.
Client: If an event is called (like add, update etc.) send
eventrequest to server
Server: Recieve event -> Process (with transactions if needed) -> reformat csv, save it
and send back to client
Client: Retrieve and apply MvvM bindings
Otherwise you need redundant csv logic in client and server whats not a fine approach.
Do you know what I mean or should I do you an example?
The csv library supports complex csv binding and easy appending like:
$csv = new parseCSV();
$csv->parse('yourcsv.csv');
$csv->data[1] = array('updatekey' => 'new Value');
$csv->save();
Client side example:
//retrieve your csv (view rendered or async with ajax
var csv;
var mutableDataArray = $.csv.toArray(csv);
//do manipulation here
//for example
mutableDataArray[0].name = 'A new name to first record';
//serialize back
var newCsv = "";
for(var i in mutableDataArray) {
var data = mutableDataArray[i].join(",");
newCsv += i < mutableDataArray[i].length ? data + "\n" : data;
}
//do something with newCsv
I am trying using the jqgrid. I set the column, and i attached to that the widget. Everything is working except the grid does not contain data. It only contains an empty row. Column, widgets (like the calendar) works.
The following is the beginning of my grid setting:
// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query
$grid->SelectCommand = "SELECT * FROM `$table_name`";
// set the ouput format to json
$grid->dataType = 'json';
$grid->table = "$table_name";
$grid->setPrimaryKeyId("matter_party_ID");
$grid->serialKey = false;
$grid->setColModel();
// Set the url from where we obtain the data
$grid->setUrl(????????);
$grid->addCol(array( etc. etc.
As you can see I am retriving the data with a a database query and returning a jason object to the grid:
// Write the SQL Query
$grid->SelectCommand = "SELECT * FROM `$table_name`";
// set the ouput format to json
$grid->dataType = 'json';
But the data is not there. After few invane searches I have been suggested to add the line:
$grid->setUrl(????????);
But I don't understand it. Why do I need to set a url if the data has been fetch on the current url using a select? Can you help?
Thank you
Watch the link. As given here when you are not assigning arrays to the jqGrid you need to provide a url from where the data can be retrieved. This is because the jqgrid needs formatted data in the form of json or xml and doesn't process resultset directly. You could select the data and process it as required as shown in the link and then use the php as a url for your jqgrid which is defined in another php file.
I am answering my own question in case someone needs to solve the same or a similar problem. In the:
$grid->setUrl(????????);
I pass a php file like grid.php that calls the function that builds the grid again!
$grid->setUrl('grid.php');
The problem is that when I generate a file through my own MVC it automatically adds a header and a footer compromising the json object returned by the grid constructor and not allowing the grid to be populated! I got rid of header and footer and the data magically reappeared!