Jump to content

bintech21

Members
  • Posts

    35
  • Joined

  • Last visited

bintech21's Achievements

Member

Member (2/5)

0

Reputation

  1. any updates please any expert here on this forum to advise on the same please?
  2. Hi Experts, Any updates on the same please? Thanks
  3. but before testing i should be knowing what should be my connection file configuration. also as per my requirement it should give functionality to upload images/logos where does that functionality come in picture in you tube link? also i have test ed you tube video that works fine on my computer but as per my requirement my conection file etc. may not work as I am not sure what code should i put inside it to make it work as i desire.
  4. Hi Experts, Any updates on the same please as I have stuck now and not sure of my work whether it's correct or not so need experts guidance to verify what I have coded with respect to my problem is correct or not? Thanks
  5. any updates please?
  6. Any updates by experts please?
  7. ok,but what is missing in my database_connection php file? ..also from myphpadmin link (which was posed earlier in this thread) i have selected database name as 'MySQL' so is some thing wrong in it? also can you please show by example what should ideally be my update statement if I am missing ":" there? were my add,delete statements were correct? also even if i try to connect and add things in this new table so called 'lockup' where is it going to serve my purpose for ' generate an XML file from it.The form has to have the ability to add items in one particular section(where we can add additional streams) and give us the ability to remove streams as well. For each stream we must be able to attach a logo for that stream as well.' this means some where from this web form we must be able to upload logo where is that functionality is getting covered here in our attempts ( as we are referring currently that you tube video)
  8. also where should i set all these options const HOST = 'localhost'; const USERNAME = '???'; const PASSWORD = '???'; const DATABASE = '???'; function pdoConnect($dbname=DATABASE) { $db = new PDO("mysql:host=".HOST.";dbname=$dbname;charset=utf8",USERNAME,PASSWORD); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); return $db; }
  9. but as given in that referral link database connection.php file does not have all these things it just have followings as stated in last post:- <?php //database_connection.php $connect = new PDO("mysql:host=localhost;dbname=MySQL", "root", ""); session_start(); $_SESSION["user_id"] = "1"; ?> also from myphpadmin link i have selected database name as MySQL so is some thing wrong in it? also can you please show by example what should ideally be my update statement if I am missing ":" there?
  10. ok,i just read it again so for index.php it seems you have corrected the execute () similarly i think for rest of other parts like add,delete,update i thnk it's correct only as i have coded -->execute($data) there? and apart from this code( for all idex,add,delete,update & DBconnection) looks good for all these transactions with respect to my problem here?
  11. so did you mean o say like i should modify my code to all the places wherever i used it like $query ' ...some sql query' i should not use this sql query here instead i should use it like this :-execute('Sql Query') ?
  12. Ok ,Thanks. I hope now following code is good with respect to my problem here ,could you please have a look on this , I have made corrections based on my understanding for new table 'lockup' and it's fields for all the important sections here to get the desired results for this new webform. ************* modified code for database_connection -Copy.php *************** <?php //database_connection.php $connect = new PDO("mysql:host=localhost;dbname=MySQL", "root", ""); session_start(); $_SESSION["user_id"] = "1"; ?> *************************************************************************************************** modified code for index -Copy.php as per new table 'lockup'. ******** <?php //index.php include('database_connection -Copy.php'); $query = " SELECT * FROM lockup WHERE user_id = '".$_SESSION["user_id"]."' ORDER BY user_id DESC "; $statement = $connect->prepare($query); $statement->execute(); $result = $statement->fetchAll(); ?> <!DOCTYPE html> <html> <head> <title>Developed To-update-add-delete items in XML section in PHP using Ajax</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" /> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <style> body { font-family: 'Comic Sans MS'; } .list-group-item { font-size: 26px; } </style> </head> <body> <br /> <br /> <div class="container"> <h1 align="center">Developed To-update-add-delete items in XML section in PHP using Ajax</h1> <br /> <div class="panel panel-default"> <div class="panel-heading"> <div class="row"> <div class="col-md-9"> <h3 class="panel-title">My To-Do List</h3> </div> <div class="col-md-3"> </div> </div> </div> <div class="panel-body"> <form method="post" id="to_do_form"> <span id="message"></span> <div class="input-group"> <input type="text" name="task_name" id="task_name" class="form-control input-lg" autocomplete="off" placeholder="Title..." /> <div class="input-group-btn"> <button type="submit" name="submit" id="submit" class="btn btn-success btn-lg"><span class="glyphicon glyphicon-plus"></span></button> </div> </div> </form> <br /> <div class="list-group"> <?php foreach($result as $row) { $style = ''; if($row["task_status"] == 'yes') { $style = 'text-decoration: line-through'; } echo '<a href="#" style="'.$style.'" class="list-group-item" id="list-group-item-'.$row["lockup_id"].'" data-id="'.$row["lockup_id"].'">'.$row["mediaurl"].' <span class="badge" data-id="'.$row["lockup_id"].'">X</span></a>'; } ?> </div> </div> </div> </div> </body> </html> <script> $(document).ready(function(){ $(document).on('submit', '#to_do_form', function(event){ event.preventDefault(); if($('#task_name').val() == '') { $('#message').html('<div class="alert alert-danger">Enter Task Details</div>'); return false; } else { $('#submit').attr('disabled', 'disabled'); $.ajax({ url:"add_task -Copy.php", method:"POST", data:$(this).serialize(), success:function(data) { $('#submit').attr('disabled', false); $('#to_do_form')[0].reset(); $('.list-group').prepend(data); } }) } }); $(document).on('click', '.list-group-item', function(){ var lockup_id = $(this).data('id'); $.ajax({ url:"update_task - Copy.php", method:"POST", data:{lockup_id:lockup_id}, success:function(data) { $('#list-group-item-'+lockup_id).css('text-decoration', 'line-through'); } }) }); $(document).on('click', '.badge', function(){ var lockup_id = $(this).data('id'); $.ajax({ url:"delete_task - Copy.php", method:"POST", data:{lockup_id:lockup_id}, success:function(data) { $('#list-group-item-'+lockup_id).fadeOut('slow'); } }) }); }); </script> ******** modified code for add_task -Copy.php as per new table 'lockup'. ******** <?php //add_task.php include('database_connection -Copy.php'); if($_POST["task_name"]) { $data = array( ':lockup_id' => $_SESSION['lockup_id'], ':mediaurl' => trim($_POST["mediaurl"]), ':imagename' => 'no' ); $query = " INSERT INTO lockup (lockup_id, mediaurl,imagename,title) VALUES (:lockup_id, :mediaurl, :imagename,title) "; $statement = $connect->prepare($query); if($statement->execute($data)) { $task_list_id = $connect->lastInsertId(); echo '<a href="#" class="list-group-item" id="list-group-item-'.$lockup_id.'" data-id="'.$lock_id.'">'.$_POST["mediaurl"].' <span class="badge" data-id="'.$lockup_id.'">X</span></a>'; } } ?> ******** modified code for delete_task -Copy.php as per new table 'lockup'. ******** <?php //delete_task.php include('database_connection -Copy.php'); if($_POST["lockup_id"]) { $data = array( ':lockup_id' => $_POST['lockup_id'] ); $query = " DELETE FROM lockup WHERE lockup_id = :lockup_id "; $statement = $connect->prepare($query); if($statement->execute($data)) { echo 'done'; } } ?> **************** modified code for update_task -Copy.php as per new table 'lockup'. *********************************** <?php //update_task.php include('database_connection -Copy.php'); if($_POST["lockup_id"]) { $data = array( ':mediaurl' => 'yes', ':lockup_id' => $_POST["lockup_id"] ); $query = " UPDATE lockup SET mediaurl = :mediaurl WHERE lockup_id = lockup_id : "; $statement = $connect->prepare($query); if($statement->execute($data)) { echo 'done'; } } ?> ************************************
  13. ok,thanks. Does my index page look good as per modified code( Just changed the fields name as this new table) based on referred example from that link:-https://www.webslesson.info/2019/08/developed-to-do-list-in-php-using-ajax.html <?php //index.php include('database_connection.php'); $query = " SELECT * FROM task_list WHERE user_id = '".$_SESSION["user_id"]."' ORDER BY task_list_id DESC "; $statement = $connect->prepare($query); $statement->execute(); $result = $statement->fetchAll(); ?> <!DOCTYPE html> <html> <head> <title>Developed To-update-add-delete items in XML section in PHP using Ajax</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" /> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <style> body { font-family: 'Comic Sans MS'; } .list-group-item { font-size: 26px; } </style> </head> <body> <br /> <br /> <div class="container"> <h1 align="center">Developed To-update-add-delete items in XML section in PHP using Ajax</h1> <br /> <div class="panel panel-default"> <div class="panel-heading"> <div class="row"> <div class="col-md-9"> <h3 class="panel-title">My To-Do List</h3> </div> <div class="col-md-3"> </div> </div> </div> <div class="panel-body"> <form method="post" id="to_do_form"> <span id="message"></span> <div class="input-group"> <input type="text" name="task_name" id="task_name" class="form-control input-lg" autocomplete="off" placeholder="Title..." /> <div class="input-group-btn"> <button type="submit" name="submit" id="submit" class="btn btn-success btn-lg"><span class="glyphicon glyphicon-plus"></span></button> </div> </div> </form> <br /> <div class="list-group"> <?php foreach($result as $row) { $style = ''; if($row["task_status"] == 'yes') { $style = 'text-decoration: line-through'; } echo '<a href="#" style="'.$style.'" class="list-group-item" id="list-group-item-'.$row["lockup_id"].'" data-id="'.$row["lockup_id"].'">'.$row["mediaurl"].' <span class="badge" data-id="'.$row["lockup_id"].'">X</span></a>'; } ?> </div> </div> </div> </div> </body> </html> <script> $(document).ready(function(){ $(document).on('submit', '#to_do_form', function(event){ event.preventDefault(); if($('#task_name').val() == '') { $('#message').html('<div class="alert alert-danger">Enter Task Details</div>'); return false; } else { $('#submit').attr('disabled', 'disabled'); $.ajax({ url:"add_task -Copy.php", method:"POST", data:$(this).serialize(), success:function(data) { $('#submit').attr('disabled', false); $('#to_do_form')[0].reset(); $('.list-group').prepend(data); } }) } }); $(document).on('click', '.list-group-item', function(){ var lockup_id = $(this).data('id'); $.ajax({ url:"update_task - Copy.php", method:"POST", data:{lockup_id:lockup_id}, success:function(data) { $('#list-group-item-'+lockup_id).css('text-decoration', 'line-through'); } }) }); $(document).on('click', '.badge', function(){ var lockup_id = $(this).data('id'); $.ajax({ url:"delete_task - Copy.php", method:"POST", data:{lockup_id:lockup_id}, success:function(data) { $('#list-group-item-'+lockup_id).fadeOut('slow'); } }) }); }); </script>
  14. just removing extra comma(,) after title field-- how does it look here? CREATE TABLE t1 ( mediaurl varchar(60), imagename varchar(60), title varchar(60) ); Now I think it's good table based on my problem here and should be able to handle values as i have used varchar here right?
  15. how does it look here? CREATE TABLE t1 ( mediaurl varchar(60), imagename varchar(60), title varchar(60), );
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.