Jump to content

Search the Community

Showing results for tags 'record'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 6 results

  1. Here's what I am trying to do. Retrieve "title" and "slug title" from all the rows in a table. Update them with new "title", "slug title" and "brand name". Here's my query. It updates the table with the brand names for each row. But for some reason, it removes the title and slug title from all the rows in the table. Is there a reason why it's doing that? function getIt($var) { $pos = strpos($var, ' - '); echo(substr($var, $pos+3)."\n"); } if(isset($_POST['submit'])) { $get_record = $db->prepare("SELECT * FROM items"); $get_record->execute(); $result_record = $get_record->fetchAll(PDO::FETCH_ASSOC); if(count($result_record) > 0){ foreach($result_record as $row) { $get_item_id = intval($row['item_id']); $get_item_title = trim($row['item_title']); $get_item_title_slug = trim($row['item_title_slug']); $new_title = getIt($get_item_title); $new_title_slug = Output::createSlug($new_title); $brand_name = substr($get_item_title, 0, strpos($get_item_title, ' - ')); $update_record = $db->prepare("UPDATE items SET brand_name = :brand_name, item_title = :item_title, item_title_slug = :item_title_slug WHERE item_id = :item_id"); $update_record->bindParam(':item_id', $get_item_id); $update_record->bindParam(':brand_name', $brand_name); $update_record->bindParam(':item_title', $new_title); $update_record->bindParam(':item_title_slug', $new_title_slug); if(!$update_record->execute()) { $errors[] = 'There was a problem updating the item.'; } } } else { $errors[] = 'No item found.'; } }
  2. All I am trying to do is add a record on a page without the page refreshing. For that ajax is used. Here is the code. It does not add the record to mysql table. Can anyone tell me what I am doing wrong? record.php <!DOCTYPE HTML> <html lang="en"> <head> <script type="text/javascript" src="js/jquery-1.11.0.min.js"></script> <script type="text/javascript" > $(function() { $(".submit_button").click(function() { var textcontent = $("#content").val(); var name = $("#name").val(); var dataString = 'content='+ textcontent + '&name='+name; if(textcontent=='') { alert("Enter some text.."); $("#content").focus(); } else { $("#flash").show(); $("#flash").fadeIn(400).html('<span class="load">Loading..</span>'); $.ajax({ type: "POST", url: "action.php", data: dataString, cache: true, success: function(html){ $("#show").after(html); document.getElementById('content').value=''; $("#flash").hide(); $("#content").focus(); } }); } return false; }); }); </script> </head> <body> <?php $record_id = $_GET['id']; // getting ID of current page record ?> <form action="" method="post" enctype="multipart/form-data"> <div class="field"> <label for="title">Name *</label> <input type="text" name="name" id="name" value="" maxlength="20" placeholder="Your name"> </div> <div class="field"> <label for="content">content *</label> <textarea id="content" name="content" maxlength="500" placeholder="Details..."></textarea> </div> <input type="submit" name="submit" value="submit" class="submit_button"> </form> <div id="flash"></div> <div id="show"></div> </body> </html> action.php if(isset($_POST['submit'])) { if(empty($_POST['name']) || empty($_POST['content'])) { $error = 'Please fill in the required fields!'; } else { try { $name = trim($_POST['name']); $content = trim($_POST['content']); $stmt = $db->prepare("INSERT INTO records(record_id, name, content) VALUES(:recordid, :name, :content"); $stmt->execute(array( 'recordid' => $record_id, 'name' => $name, 'content' => $content )); if(!$stmt){ $error = 'Please fill in the required fields.'; } else { $success = 'Your post has been submitted.'; } } catch(Exception $e) { die($e->getMessage()); } } }
  3. Right now I redirect to index page after I delete a record. However I am looking to make it so that I can delete a record without redirecting the page. I know this can be accomplised using Ajax. I have spent countless hours before trying to make it work, but it did not work. So here is a basic setup I created. Can you please update it with ajax code so that I can see how it's done properly? <!DOCTYPE HTML> <html lang="en"> <head> <meta charset="UTF-8"> <title>Home Page</title> </head> <body> <div class="record" > <a href="record.php?id=<?php echo $record_id ?>"><?php echo $record_name; ?></a> <div class="delete-record"> <a href="delete.php">Delete Record</a> </div> </div> </body> </html>
  4. I am trying to have a js alert box to confirm before deleting a record. Here is the js code. <script> function confirmation() { var answer = confirm("Are you sure?") if (answer){ alert("This record been deleted!") } else{ alert("Not deleted!") } } </script> php code. <a href="delete.php" onclick="confirmation()">Delete record</a> The problem is, even if i click no in the js alert box and the message shows("Not deleted!"), it still deletes the record. Why is it doing that? My second question is, is it possible to css the js alert box? I need to customize it to my own look.
  5. Hi Folks, I am new here and I am building a dummy business application for my school project. So I am still learning from you guys and please guide me with what i have right now. So, I want to populate a dropdown list with rows that exists in my Oracle DB and that would be my COMPONENT_ID column. When i pull that component ID column and select one of them, I need to show the corresponding data that show progress from that particular item. So when i choose one of the ID, I need to show the rest of the column that is in the same row with that particular item. What i have right now is this. I am assuming this will only pull the component ID but it doesnt work either. So please help me... <?php $paint_parse = oci_parse($conn, 'SELECT HEAD_MARK FROM FABRICATION'); oci_execute($paint_parse, OCI_DEFAULT); // Count the number of occurence inside the table $result = array(); $numrows = oci_fetch_all($paint_parse, $result, null, null, OCI_FETCHSTATEMENT_BY_ROW); while ($row = oci_fetch_array($paint_parse, OCI_ASSOC)!= false){ $value = $row['HEAD_MARK']; echo "<option value = $value>$value</option>"; } ?>
  6. I have this HTML FORM <form action="check_record.php" method="post"> <input type="text" placeholder=""Last Name" name="lname"></input> <input type="text" placeholder=""First Name" name="fname"></input> SUBMIT or CLEAR </form> once the user submits the form I point it to the check_record.php to check if the record already exist or not <?php //check_record.php session_start(); $connection = mysql_connect("localhost", "root", ""); $db = mysql_select_db("web", $connection); $sql="SELECT * FROM `web`.`tbl_student` WHERE lname = '".$_POST["lname].'", fname = '".$_POST["fname"]."' $result = mysql_query($sql); $row = (I forgot the next codes :\) header("Location:add_record.php"); ?> <?php //add_record.php session_start(); $connection = mysql_connect("localhost", "root", ""); $db = mysql_select_db("web", $connection); $sql="INSERT INTO `web`.`tbl_student` (`lname`, `fname`) VALUES ('".$_POST["lname].'", '".$_POST["fname"]."')"; $result = mysql_query($sql); header("Location:index.php"); ?> I am totally new to PHP, my problem here is, once the user submits the form, it will check if the last name or the first name already exist, if it exist it will not allow to add the record and displays a message "Record alreadys exist" if it's not an existing record, it will display a message saying "Record saved." I have no problem with adding, updating, or deleting a record. During our lab activity I figured out how to check if the record already exist but I'm not sure about because after the record has been check and it's not existing it will add though but the last name and the first name are blank :/ please help
  • 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.