Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • 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

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. I have made an ajax call (using file activedirectory.php) to active directory to retrieve information such as name,thumbnail photo,mail etc. the ajax call is made on click of a name in a leaderboard ,to fetch only that person's info by matching the post['id']. The problem is that I am unable to retrieve any information and the console gives me an error saying : SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data the error type makes it clear that it is unable to pull any data whatsoever. .php file that has been used here :(activedirectory.php) -- <?php /** * Get a list of users from Active Directory. */ $ad_users = ''; $message = ''; $ldap_password = 'Qwerty@33xxxxxx'; $ldap_username = 'maxxxxxxxxxxxx'; $server = 'ldap://xxxxxxxxxx'; $domain = '@asia.xxxxxx.com'; $port = 389; $ldap_connection = ldap_connect($server, $port); if (FALSE === $ldap_connection){ // Uh-oh, something is wrong... } // We have to set this option for the version of Active Directory we are using. ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3) or die('Unable to set LDAP protocol version'); ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, 0); // We need this for doing an LDAP search. if (TRUE === ldap_bind($ldap_connection, $ldap_username.$domain, $ldap_password)){ $base_dn = "OU=Employees,OU=Accounts,OU=xxxxx,DC=xxxxx,DC=xxxxxx,DC=com"; $kid = 'NonExistingAccount'; if (preg_match('#SAM_NAME_MATCHING_REGEX#', $_POST['id'])) { $kid = $_POST['id']; } $search_filter = "(&(objectCategory=person)(samaccountname={$kid}))"; $attributes = array(); $attributes[] = 'givenname'; $attributes[] = 'mail'; $attributes[] = 'samaccountname'; $attributes[] = 'sn'; $result = ldap_search($ldap_connection, $base_dn, $search_filter, $attributes); $maxPageSize = 1000; if (FALSE !== $result){ $entries = ldap_get_entries($ldap_connection, $result); for ($x=0; $x<$entries['count']; $x++){ if (!empty($entries[$x]['givenname'][0]) && !empty($entries[$x]['mail'][0]) && !empty($entries[$x]['samaccountname'][0]) && !empty($entries[$x]['sn'][0]) && 'Shop' !== $entries[$x]['sn'][0] && 'Account' !== $entries[$x]['sn'][0]){ $ad_users[strtoupper(trim($entries[$x]['samaccountname'][0]))] = array('email' => strtolower(trim($entries[$x]['mail'][0])),'first_name' => trim($entries[$x]['givenname'][0]),'last_name' => trim($entries[$x]['sn'][0])); } } } ldap_unbind($ldap_connection); // Clean up after ourselves. } $message .= "Retrieved ". count($ad_users) ." Active Directory users\n"; ?> the javascript that has been used here : $('.leaderboard li').on('click', function () { $.ajax({ url: "../popupData/activedirectory.php", // your script above a little adjusted type: "POST", data: {id:$(this).find('.parent-div').data('id')}, success: function(data){ console.log(data); data = JSON.parse(data); $('#popup').fadeIn(); //whatever you want to fetch ...... // etc .. }, error: function(){ alert('failed, possible script does not exist'); } }); });
  2. So, I am trying to create a website where you enter a pin, it redirects you to a page, enter another pin, it redirects you to another page. I have two files: th1.php (the main file) <?php //require_once"app/init.php ;?> <!DOCTYPE HTML> <link rel="stylesheet" type="text/css" href="style.css" /> <form action="th.php" method="POST"> <div class="container"> <input type="text" placeholder="Enter PIN" name="pin" required> <button type="submit" name="sub" value="Submit">Submit</button> </div> <div class="container" style="background-color:#f1f1f1"> </div> </form> and th.php (the verification file) <?php if(isset($POST['pin']) AND !empty($POST['pin'])){ $input = $_POST['pin']; $pinI = "6203"; $pinII = "9471"; if($input === $pinI){ header("Location:pinI.html"); }else{ if($input === $pinII){ header("Location:pinII.html"); }else{ echo "PIN INCORRECT!"; }} }else{ echo "PIN EMPTY!"; } but any code I insert, even the correct one, it sais PIN EMPTY! can you help me please?
  3. Basically I am having an array something like below, this array has number of categories and sub, sub sub categories. $categories = array( array('id' => 1, 'parent' => 0, 'name' => 'Category'), array('id' => 2, 'parent' => 1, 'name' => 'Category A'), array('id' => 3, 'parent' => 1, 'name' => 'Category B'), array('id' => 4, 'parent' => 1, 'name' => 'Category C'), array('id' => 5, 'parent' => 1, 'name' => 'Category D'), array('id' => 6, 'parent' => 1, 'name' => 'Category E'), array('id' => 7, 'parent' => 2, 'name' => 'Subcategory F'), array('id' => 8, 'parent' => 2, 'name' => 'Subcategory G'), array('id' => 9, 'parent' => 3, 'name' => 'Subcategory H'), array('id' => 10, 'parent' => 4, 'name' => 'Subcategory I'), array('id' => 11, 'parent' => 9, 'name' => 'Subcategory J'), ); Using this array I have created a nested <ul>. This is the recursive function I have used for : foreach ($categories as $category) { $id = $category['id']; $parent = $category['parent']; $name = $category['name']; //echo $name."<br>"; $cats[$parent][$id] = $name; } function displayList(&$cats, $parent, $current=0, $level=0) { switch ($level) { case 0: $class = "level_1 has_sub no_active"; $a_class = "c1"; break; case 1: $class = "level_2 has_sub no_active"; $a_class = "c2"; break; case 2: $class = "level_3 has_sub no_active"; $a_class = "c3"; break; } if ($parent==0) { foreach ($cats[$parent] as $id=>$nm) { if (isset($cats[$id])) { displayList($cats, $id, $current); } } } else { echo "<ul class='$class'>\n"; foreach ($cats[$parent] as $id=>$nm) { $clear = preg_replace('/[^a-zA-Z0-9\s]/', '', strip_tags(html_entity_decode($nm))); $pageName = strtolower(str_replace(' ', '-', $clear)); $link = $pageName.'.php'; echo "<li><a href='$link' class='$a_class $sel'><span>$nm</span></a>\n"; if (isset($cats[$id])) { displayList($cats, $id, $current, $level+1); } echo '</li>'; } echo "</ul>\n"; } } Look at that function, I have created a link for each category. Category name itself has used as page name. (Removing by special chars.) My question is, when this function executing I want to create folders for level one categories. Those category names should be used as folder names. Example from above array: category_a category_b category_c category_d category_e So, every sub category pages should be inside these parent category folders. Can I know is this possible in this function? Thank you.
  4. Hi there, I was trying to do a live table edit for our site. Everything seemed to be going ok, till i realised that its not actually updating the database, there are no error messages, you have to refresh the page to see it hasn't worked. I'm at a loss as to why was hoping someone might be able to point me in the right direction. thanks, MsKazza tableedit.php table_edit_ajax.php
  5. good day dear php-freaks i need to rename files in _ one _ directory - more than 50 files are in this..folder: the files are named like so: 01 02 03 04 ... 49 50 each file has got a number as a file name. each file should get a character - like so: r01, r02, r03, r04 and so on . .... r50 how can we do this on commandline
  6. hi, On my website I have a form with a single text area and a submit button, the user will come to my site with a report of points and stats from hosting a tournament online, see attached picture for details of the report once they hit submit the form posts to my processing page, in the processing page I take all the information I need from the beginning of the report this was kind of easy to do, the part I seem to be struggling with is splitting the array at this point. I have exploded each line from my report into an array $records, what I need to do now is, take everything from the line "START POINTS" down to the line "STOP POINTS" from the main array into a new array so that I can get the new array and use a foreach loop on it to separate the player name from player points I already have the foreach loop setup ready as I had this all setup once but I was not getting the information from the top of the report now I need that information so my original foreach does not work
  7. We can create .php files every time I click on it will check to Simple "E: /e.txt" and read inside it and create / wirte to print .php file hosting We can create .php files every time I click on it will check to Simple "E: /e.txt" and read inside it and create / wirte to print .php file hosting?? , please help
  8. Hi again, Hopefully the last question as I am not 100% how to solve this one. So on my website someone carried out a search from a search bar using the 'POST' method , teh search results show all whiskies in the databse. I have a number of whiskies with the same name but with different dates and prices. I would like it just to show one of each type that was searched for rather than all of them. I have attahced a clip of the databse. Thanks Index.php </head> <?php $page='index'; include('header.php'); include('navbar.php'); ?> <script type="text/javascript"> function active(){ var search_bar= document.getElementById('search_bar'); if(search_bar.value == 'Search for your whisky here'){ search_bar.value='' search_bar.placeholder= 'Search for your whisky here' } } function inactive(){ var search_bar= document.getElementById('search_bar'); if(search_bar.value == ''){ search_bar.value='Search for your whisky here' search_bar.placeholder= '' } } </script> <body> <div class="third_bar"> <div class="background_image"> </div> <div class="form"><form action= "search.php" method="post"> <input type="text" name="search" id="search_bar" placeholder="" value="Search for your whisky here" max length="30" autocomplete="off" onMouseDown="active();" onBlur="inactive();"/><input type="submit" id="search_button" value="Go!"/> </form> </div> </div> </body> </div> <?php include ('footer.php'); ?> Search.php <?php $page='search'; include('header.php'); include ('navbar.php'); echo "<br>"; include ('connect.php'); if (isset ($_POST['search'])) { //the 'search' refers to the 'search' name=search on the index page and makes does something when the search is pushed. $search = $_POST['search']; $search = "%" . $search . "%"; // MySQL wildcard % either side of search to get partially matching results // No wildcard if you want results to match fully } else { header ('location: index.php'); } $stmt = $conn->prepare("SELECT * FROM test_db WHERE name LIKE :name ORDER BY name ASC"); // Use = instead of LIKE for full matching $stmt->bindParam(':name', $search); $stmt->execute(); $count = $stmt->rowCount(); // Added to count no. of results returned if ($count >= 1) { // Only displays results if $count is 1 or more echo "<div class='results_found'>"; echo $count; echo " results found<br>"; echo "</div>"; while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo "<div class='results'>"; echo "<div class='result_name'>"; echo "<b>Whisky Name:</b><br>"; echo "<a href='details1.php?id={$row['lot_id']}' >{$row['name']}</a>"; echo"<br>"; echo "</div>"; echo "</div>"; } } else { echo " Sorry no records were found"; } ?> </htm
  9. Hi I have a question about managing data from forms and database, to be exact for safe input/output data from form input fields. Do i need some filters to remove code from input if user try to insert ? When i making database table i limiting chars and same in form. Here is a piece of code i use just for test and example : // connection to database $dbh = new PDO('mysql:host=localhost;dbname=test123', 'root', ''); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // variables to insert into database $username = $_POST['username']; $password = $_POST['password']; $email = $_POST['email']; // query with prepare statements $stmt = $dbh->prepare("INSERT INTO members (username, password, email) VALUES (:username, :password, :email)"); $stmt->bindParam(":username", $username, PDO::PARAM_STR); $stmt->bindParam(":password", $password, PDO::PARAM_STR); $stmt->bindParam(":email", $email, PDO::PARAM_STR); $stmt->execute(); $lastId = $dbh->lastInsertId(); // checking if query is passed and data is inserted into dataabse if($lastId > 0) { echo 'Thank u for register.'; } else { echo 'Something went wrong, please try again.'; }
  10. I have this code that pulls data from a form and is supposed to check if the neptune and username are inserted 2 times it replies back with an error if not it posts the data to 2 lines with neptune username and email on one line and just email and username on the other The issue is the code i have gives me an error saying unexpected end of file below is my code any help will be appreciated <?php if(isset($_POST['choices']) && !empty($_POST['choices'])){ if($_POST['choices'] == 'four'){ //variables from form entered $username = $_POST['username']; $neptune = $_POST['neptune']; $email = $_POST['useremail']; //connect to the database $dbc = mysqli_connect('localhost', 'root', '', 'happygam_main') or die('Error connecting to MySQL server'); $check=mysqli_query($dbc,"select * from ballot where username='$username' and neptune='$neptune'"); $checkrows=mysqli_num_rows($check); if($checkrows>0) { echo "This combination of neptune and username has already been processed"; } else { //insert results from the form input in 2 rows one with neptune one without $query = "INSERT IGNORE INTO ballot(username, useremail, neptune) VALUES('$username', '$email', '$neptune')"; $query1 = "INSERT IGNORE INTO ballot(username, neptune) VALUES('$username', '$neptune')"; $result = mysqli_query($dbc, $query, $query1) or die('Error querying database.'); mysqli_close($dbc); } } ?>
  11. I have just begun dabbling with javascript as a hobby and have a very crude understanding of php so please bare with me, I am a noob! I am using a javascript onclick button to reference the function shown below. function deleteReply(fpid) { $.post("ajax_forumdelete.php", {'reply': fpid}, function (d) { }); location.reload(); } When the button is pressed and the function executes it does as it should. It deletes the forum reply post as its told and the page reloads and the post is gone! But without some sort of explanation, success message or something telling me that it did what its intended is very unsatisfying. I read around and found that an additional function is needed to give me a little message. success : function() { var x="Success"; alert(x); } Looks simple enough and one would think should be easy to incorporate but when I add it in every way shape or form I cannot get it to work. The original function wont even work after adding this. Below is basically what I am wanting to do but not quite sure how to go about it. function deleteReply(fpid) { $.post("ajax_forumdelete.php", {'reply': fpid}, function (d) { }); success : function() { var x="<?php $mtg->success("Reply has been deleted."); ?>"; alert(x); location.reload(); } } I want to use the php $mtg->success() function to echo the message in the pre defined output location and format and want to output the message after the reload... Any ideas on how to go about this?
  12. Hey guys. I have this php code and it tells me there a problem, but I can seem to figure out what the problem is. Hope you can help. Here is the code - mysql_query("INSERT INTO `wp_dc_mv_configuration` (`id`, `palettes`, `administration`) VALUES (1, 'a:2:{i:0;a:3:{s:4:\"name\";s:7:\"Default\";s:6:\"colors\";a:70:{i:0;s:3:\"FFF\";i:1;s:3:\"FCC\";i:2;s:3:\"FC9\";i:3;s:3:\"FF9\";i:4;s:3:\"FFC\";i:5;s:3:\"9F9\";i:6;s:3:\"9FF\";i:7;s:3:\"CFF\";i:8;s:3:\"CCF\";i:9;s:3:\"FCF\";i:10;s:3:\"CCC\";i:11;s:3:\"F66\";i:12;s:3:\"F96\";i:13;s:3:\"FF6\";i:14;s:3:\"FF3\";i:15;s:3:\"6F9\";i:16;s:3:\"3FF\";i:17;s:3:\"6FF\";i:18;s:3:\"99F\";i:19;s:3:\"F9F\";i:20;s:3:\"BBB\";i:21;s:3:\"F00\";i:22;s:3:\"F90\";i:23;s:3:\"FC6\";i:24;s:3:\"FF0\";i:25;s:3:\"3F3\";i:26;s:3:\"6CC\";i:27;s:3:\"3CF\";i:28;s:3:\"66C\";i:29;s:3:\"C6C\";i:30;s:3:\"999\";i:31;s:3:\"C00\";i:32;s:3:\"F60\";i:33;s:3:\"FC3\";i:34;s:3:\"FC0\";i:35;s:3:\"3C0\";i:36;s:3:\"0CC\";i:37;s:3:\"36F\";i:38;s:3:\"63F\";i:39;s:3:\"C3C\";i:40;s:3:\"666\";i:41;s:3:\"900\";i:42;s:3:\"C60\";i:43;s:3:\"C93\";i:44;s:3:\"990\";i:45;s:3:\"090\";i:46;s:3:\"399\";i:47;s:3:\"33F\";i:48;s:3:\"60C\";i:49;s:3:\"939\";i:50;s:3:\"333\";i:51;s:3:\"600\";i:52;s:3:\"930\";i:53;s:3:\"963\";i:54;s:3:\"660\";i:55;s:3:\"060\";i:56;s:3:\"366\";i:57;s:3:\"009\";i:58;s:3:\"339\";i:59;s:3:\"636\";i:60;s:3:\"000\";i:61;s:3:\"300\";i:62;s:3:\"630\";i:63;s:3:\"633\";i:64;s:3:\"330\";i:65;s:3:\"030\";i:66;s:3:\"033\";i:67;s:3:\"006\";i:68;s:3:\"309\";i:69;s:3:\"303\";}s:7:\"default\";s:3:\"F00\";}i:1;a:3:{s:4:\"name\";s:9:\"Semaphore\";s:6:\"colors\";a:3:{i:0;s:3:\"F00\";i:1;s:3:\"FF3\";i:2;s:3:\"3C0\";}s:7:\"default\";s:3:\"3C0\";}}', 'a:15:{s:5:\"views\";a:4:{i:0;s:7:\"viewDay\";i:1;s:8:\"viewWeek\";i:2;s:9:\"viewMonth\";i:3;s:10:\"viewNMonth\";}s:11:\"viewdefault\";s:5:\"month\";s:8:\"language\";s:5:\"en-GB\";s:13:\"start_weekday\";s:1:\"0\";s:8:\"cssStyle\";s:9:\"cupertino\";s:12:\"paletteColor\";s:1:\"0\";s:6:\"btoday\";s:1:\"1\";s:11:\"bnavigation\";s:1:\"1\";s:8:\"brefresh\";s:1:\"1\";s:14:\"numberOfMonths\";s:2:\"12\";s:7:\"sample0\";N;s:7:\"sample1\";s:5:\"click\";s:7:\"sample2\";N;s:7:\"sample3\";s:0:"";s:7:\"sample4\";s:10:\"new_window\";}');");
  13. Hi I have been working on my OOP and have put together some class files to aid my test application ( photo album ) on the upload page I have the browse box, a caption text box and an upload button this page posts to self, Once you click on upload it is also supposed to insert a database entry to allow tracking of the file's attributes, once I click the upload button I get this error message back, " Database Query Failed: Incorrect integer value ' ' for column 'id' at row 1 " so I have re looked over my codes in regards to uploading files and just can not seem to put my mouse on the spot that's causing me an issue so here is the codes that matter to the file uploads... this one is from my database.php class file, public function insert_id() { // get the last id inserted over the current db connection return mysql_insert_id($this->connection); } and this one is one comes from my photograph class file, public function create() { global $database; $attributes = $this->sanitized_attributes(); $sql = "INSERT INTO ".self::$table_name." ("; $sql .= join(", ", array_keys($attributes)); $sql .= ") VALUES ('"; $sql .= join("', '", array_values($attributes)); $sql .= "')"; if($database->query($sql)) { $this->id = $database->insert_id(); return true; } else { return false; } } Looking at my error and the information in those functions I can guess that's where the issue is coming from just don't get why any ideas please?
  14. I have a form with a table with columns and many rows. The form uses Post and submits to an insert.php I am looking for an example of how I can insert the table info into a mysql table. I know I should use a while loop but unsure how to step through the form info. Can someone suggest or provide and example that I can follow, or a tutorial somewhere? Thanks
  15. Hi, I have an application where during registration a user will choose when they want to be reminded of an event. For instance the event lets say will start on 2017-02-02 and i scheduled it on 2016-12-30 and i want to be reminded everyday from 10days to the event date(2017-02-02). How do i go about it? I need idea as to know how to go about it. I dont know if cron will be good. Thanks
  16. update super set `name` = REPLACE(`name`, ',' , ' ') I have the following code that removes the comma in a MySQL database column & replaces it with a blank. In the above example, the database is named super & the column is named name. This code works great but currently I'm running the script each day & changing it to also remove periods, question marks, etc. Is there a way I can edit the above code that will not only find & replace the , with a blank space, but edit it so it will find the periods, commas, question mark, exclamation mark, etc all in one run? Please help as I am currently editing the above code to numerous other things to find & replace daily. Thank
  17. Hi I have a question about API keys and security. I am building a mobile app (learning) and will be using a PHP/MySQL JSON Rest API (designed myself) and I am new to APIs in general so some best practices would be appreciated if you have any? My real question is to do with securing these APIs. For example I was thinking of using user name and password that the user logs into the application with to be send over HTTPS for each request to validate the user is authorised and authenticated. However I have read that I should also be using API keys, so how would I integrate this in? Would each user have their own unique API key or would each system that uses this API have a unique key? If its each user that has their own key would I send all three pieces of data with the request (API Key, username and password). Any advice would be great. Thanks
  18. I have seen a lot of demos or sort of the same questions with the Select All option. But what I want is to just have a drop down that will allow me to select All option and not showing the entire Select box. Individual Select option works but not when I tried to use ALL as an option. Here is my sample HTML: <select name="status" id="status" style="width: 224px;"> <option value="" selected="selected">Please select...</option> <option value="All">All</option> <option value="Option1">Option1</option> <option value="Option2">Option2</option> <option value="Option3">Option3</option> <option value="Option4">Option4</option> </select> From the code above I would want to filter the result using the All option. So this is the page is where I filter and show the results in a table, <script> $(document).ready(function(){ $("#results").show(); }); </script> <script type="text/javascript"> $(document).ready(function(){ $("#RetrieveList").on('click',function() { var status = $('#status').val(); var date = $('#Date').val(); var date1 = $('#Date1').val(); $.post('retrieve_status.php',{status:status, date:date, date1:date1}, function(data){ $("#results").html(data); }); return false; }); }); </script> <form id="form2" name="form2" method="post" action=""> <table width="941" border="0" align="center"> <tr> <th width="935" colspan="9" scope="col">Status: <select name="status" id="status" style="width: 224px;"> <option value="" selected="selected">Please select...</option> <option value="All">All</option> <option value="Option1">Option1</option> <option value="Option2">Option2</option> <option value="Option3">Option3</option> <option value="Option4">Option4</option> </select> Start Date:<input type="text" name="Date" id="Date" size="8"/> End Date:<input type="text" name="Date1" id="Date1" size="8"/> <input name="action" type="submit" id="RetrieveList" value="Retrieve List" /> </th> </tr> </table> </form> <div id="results"> </div> And this is how I fetch the data, <?php require 'include/DB_Open.php'; $status = $_POST['status']; $date = $_POST['date']; $date1 = $_POST['date1']; if ($_POST['status'] == 'ALL') { $sql_status = '1'; } else { $sql_status = "status = '".mysql_real_escape_string($_POST['status'])."'"; } $sql="SELECT column1, column2, status FROM tracker WHERE status = '" . $sql_status . "' AND scheduled_start_date BETWEEN '" . $date . "' AND '" . $date1 . "' ORDER BY scheduled_start_date"; $myData = mysql_query($sql); //to count if there are any results $numrow = mysql_num_rows($myData); if($numrow == 0) { echo "No results found."; } else { echo "CRQ Count: $numrow"; } { echo "<table width='auto' cellpadding='1px' cellspacing='0px' border=1 align='center'> <tr> <th align='center'><strong>Column1</strong></th> <th align='center'><strong>Column2</strong></th> <th align='center'><strong>Status</strong></th> </tr>"; while($info = mysql_fetch_array($myData)) { echo "<form action='retrieve_status.php' method='post'>"; echo"<tr>"; echo "<td align='center'>" . $info['column1'] . "<input type=hidden name=column1 value=" . $info['column1'] . " </td>"; echo "<td align='center'>" . $info['column2'] . "<input type=hidden name=column2 value=" . $info['column2'] . " </td>"; echo "<td align='center'>" . $info['status'] . "<input type=hidden name=status value=" . $info['status'] . " </td>"; echo "</tr>"; echo "</form>"; } } echo "</table>"; include 'include/DB_Close.php'; ?>
  19. Hi guys, How can i process the value of a search result. this is what i've tried so far: //searche result page if(isset($_POST['submit'])){ $_SESSION['from'] = $_POST['from']; $_SESSION['to'] = $_POST['to']; $sql = ("SELECT * FROM $tbl_name WHERE date_order BETWEEN '$_SESSION[from]' AND '$_SESSION[to]'"); //$stmt = $pdo->prepare("SELECT * FROM ca_processed"); $stmt=$pdo->query($sql); $stmt->execute(); $num_rows = $stmt->rowCount(); #print "<p>$num_rows Record(s) Found.</p>"; if($stmt->rowCount() < 1){ echo '<div class="alert alert-warning text-center">NO RECORD FOUND</div>'; }else{ print "<p>$num_rows Record(s) Found.</p>"; <form action="ReconcileAccounts" method="post"> <table width="100%" class='table-responsive table-condensed table-striped'> <tr> <td bgcolor="#444444"><font color='#fff'></font></td> <td bgcolor="#444444"><font color='#fff'><strong>#</strong></font></td> <td bgcolor="#444444"><font color='#fff'>Trans Ref</font></td> <td bgcolor="#444444"><font color='#fff'>Service Provider</font></td> <td bgcolor="#444444"><font color='#fff'>Service Type</font></td> <td bgcolor="#444444"><font color='#fff'><strong>($) Amount</strong></font></td> <td bgcolor="#444444"><font color='#fff'><strong>Date Paid</strong></font></td> <td bgcolor="#444444"><font color='#fff'><strong>Reconcile Status</strong></font></td> </tr> <?php $i = 1; while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $trans_ref = $row['trans_ref']; $service_provider = $row['service_provider']; $service_type = $row['service_type']; $amount_paid = number_format($row['amount_paid'],2); $date_paid = $row['date_paid']; $reconcile_status = $row['reconcile_status']; if($reconcile_status == 0){ $reconcile_status = "<strong>NOT RECONCILED</strong>"; }elseif($reconcile_status == 1){ $reconcile_status = "<strong>RECONCILED</strong>"; } $reconcile_info = [ 'trans_ref' => $trans_ref, 'service_provider' => $service_provider, 'service_type' => $service_type, 'amount_paid' => $amount_paid, 'date_paid' => $date_paid, 'reconcile_status' => $reconcile_status ]; $_SESSION['reconcile_info'] = $reconcile_info; ?> <tr> <td align="center"><input name="check_list[]" type="checkbox" value="<?php echo $row['id']; ?>" ></td> <td><?php echo $i++; ?></td> <td><?php echo $trans_ref; ?></td> <td><?php echo $service_provider; ?></td> <td><?php echo $service_type; ?></td> <td><?php echo $amount_paid; ?></td> <td><?php echo $date_paid; ?></td> <td><?php echo $reconcile_status; ?></td> </tr> <?php } ?> </table> <input name="reconcile" type="submit" class="btn btn-primary btn-margin" id="reconciled" value="RECONCILE SELECTED"> </form> } } //ReconcileAccounts $tbl_name="xbp_paid_bills"; //your table name $tbl_name2="xbp_registration_info"; if(isset($_POST['reconcile'])){ if(!empty($_POST['check_list'])){ foreach($_POST['check_list'] as $selected){ $stmt = $pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING ); $stmt = $pdo->prepare("UPDATE xbp_paid_bills SET reconcile_status =1 WHERE trans_id='$selected'"); $stmt->execute(); $count = $stmt->rowCount(); } if($count){ echo "<div class='bg-success alert alert-success text-center'>RECORD(S) RECONCILED</div>"; $url = "ReconcileAccount"; echo '<meta http-equiv="refresh" content="3;URL=' . $url . '">'; }else{ echo "<div class='bg-warning alert alert-warning text-center'>A PROBLEM OCCURED WHILE RECONCILING RECORD</div>"; echo "<br>"; print_r($stmt->errorInfo()); } } } thanks
  20. Hello guys, I'm try to sum rows in a UNION but having a hard time about it $stmt = $pdo->prepare("SELECT due_date, SUM(amount_paid) FROM ( SELECT due_date, amount_paid FROM table1 union all SELECT due_date, amount_paid FROM table2 UNION ALL )x GROUP BY MONTH"); $stmt->execute(); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo $row['x']; thanks
  21. Hi, I have a problem. I am doing one little job with php and html. In html i have textbox in which person id must be entered (11 numbers) I need to do with php that when all 11 numbers are entered, date of birth and gender need to be shown, For example: if id is : 39310121111 first number stands for mele/female (if 3 mele if 4 female) all next numbers are date of birth 1993 10 12 (last 4 numbers doesnt have meaning) Basicly question is. how to make syntax that entered id will be shown as gender and date of birth ? can't think of any ideas. new at php.
  22. I'm trying to save some json data to an mysql table through php but I do have some issues I'm just stuck into the loop and the validation doesn't go like I want to. These are some dummy data of the json Object [entiteteTeReja] => Array ( [cmimeReja] => Array ( [0] => Array ( [KODNIVELCMIMI] => N1 [KODARTIKULLI] => BOBLT0009 [KODNJESIA1] => cope [MONEDHAKOD] => LEK [DTFILLIMIT] => 2015-01-01T00:00:00.000Z [DTMBARIMIT] => 9999-12-31T00:00:00.000Z [CMIMI] => 3450 [CMIMI2] => 3450 [KODNJESIA2] => cope [DTMODIFIKIM] => 2015-05-11T16:42:45.046Z [IDSTATUSDOK] => 1 [BRUTONETONIVELCMIMI] => 1 [NIVELCMIMIBAZE] => [KOHEFILLIMI] => 1900-01-01T00:00:00.000Z [KOHEMBARIMI] => 1900-01-01T23:59:59.000Z ) . . . . [834] => Array ( [KODNIVELCMIMI] => N2 [KODARTIKULLI] => BOBLT0009 [KODNJESIA1] => cope [MONEDHAKOD] => LEK [DTFILLIMIT] => 2015-01-01T00:00:00.000Z [DTMBARIMIT] => 9999-12-31T00:00:00.000Z [CMIMI] => 3450 [CMIMI2] => 3450 [KODNJESIA2] => cope [DTMODIFIKIM] => 2015-05-12T16:58:24.746Z [IDSTATUSDOK] => 1 [BRUTONETONIVELCMIMI] => 1 [NIVELCMIMIBAZE] => [KOHEFILLIMI] => 1900-01-01T00:00:00.000Z [KOHEMBARIMI] => 1900-01-01T23:59:59.000Z ) . . . . [834] => Array ( [KODNIVELCMIMI] => N3 [KODARTIKULLI] => BOBLT0009 [KODNJESIA1] => cope [MONEDHAKOD] => LEK [DTFILLIMIT] => 2015-01-01T00:00:00.000Z [DTMBARIMIT] => 9999-12-31T00:00:00.000Z [CMIMI] => 3450 [CMIMI2] => 3450 [KODNJESIA2] => cope [DTMODIFIKIM] => 2015-05-12T16:58:24.746Z [IDSTATUSDOK] => 1 [BRUTONETONIVELCMIMI] => 1 [NIVELCMIMIBAZE] => [KOHEFILLIMI] => 1900-01-01T00:00:00.000Z [KOHEMBARIMI] => 1900-01-01T23:59:59.000Z ) lso this is the Php Script that I tried so far, foreach($obj['entiteteTeReja']['cmimeReja'] as $key => $x){ $query = "SELECT COUNT(*) AS nr FROM cmimedatatable WHERE KODARTIKULLI = '".$x['KODARTIKULLI']."' "; $result = $mysqli->query($query); if( nr == 1){ if($x['KODNIVELCMIMI'] == 'N1'){ $query = "UPDATE cmimedatatable SET C1 = ".$x['CMIMI']." WHERE KODARTIKULLI = '".$x['KODARTIKULLI']."' "; } else if($x['KODNIVELCMIMI'] == 'N2'){ $query = "UPDATE cmimedatatable SET C2 = ".$x['CMIMI']." WHERE KODARTIKULLI = '".$x['KODARTIKULLI']."' "; } else if($x['KODNIVELCMIMI'] == 'N3'){ $query = "UPDATE cmimedatatable SET C3 = ".$x['CMIMI']." WHERE KODARTIKULLI = '".$x['KODARTIKULLI']."' "; } else if($x['KODNIVELCMIMI'] == 'N4'){ $query = "UPDATE cmimedatatable SET C4 = ".$x['CMIMI']." WHERE KODARTIKULLI = '".$x['KODARTIKULLI']."' "; } else if($x['KODNIVELCMIMI'] == 'N5'){ $query = "UPDATE cmimedatatable SET C5 = ".$x['CMIMI']." WHERE KODARTIKULLI = '".$x['KODARTIKULLI']."' "; } else if($x['KODNIVELCMIMI'] == 'N6'){ $query = "UPDATE cmimedatatable SET C6 = ".$x['CMIMI']." WHERE KODARTIKULLI = '".$x['KODARTIKULLI']."' "; } } else if ( nr == 0){ if($x['KODNIVELCMIMI'] == 'N1'){ $query = "INSERT INTO cmimedatatable(KODARTIKULLI, C1,C2, C3, C4, C5, C6) VALUES('".$x['KODARTIKULLI']."',".$x['CMIMI'].",0,0,0,0,0)"; } else if($x['KODNIVELCMIMI'] == 'N2'){ $query = "INSERT INTO cmimedatatable(KODARTIKULLI, C1,C2, C3, C4, C5, C6) VALUES('".$x['KODARTIKULLI']."',0,".$x['CMIMI'].",0,0,0,0)"; } else if($x['KODNIVELCMIMI'] == 'N3'){ $query = "INSERT INTO cmimedatatable(KODARTIKULLI, C1,C2, C3, C4, C5, C6) VALUES('".$x['KODARTIKULLI']."',0,0,".$x['CMIMI'].",0,0,0)"; } else if($x['KODNIVELCMIMI'] == 'N4'){ $query = "INSERT INTO cmimedatatable(KODARTIKULLI, C1,C2, C3, C4, C5, C6) VALUES('".$x['KODARTIKULLI']."',0,0,0,".$x['CMIMI'].",0,0)"; } else if($x['KODNIVELCMIMI'] == 'N5'){ $query = "INSERT INTO cmimedatatable(KODARTIKULLI, C1,C2, C3, C4, C5, C6) VALUES('".$x['KODARTIKULLI']."',0,0,0,0,".$x['CMIMI'].",0)"; } else if($x['KODNIVELCMIMI'] == 'N6'){ $query = "INSERT INTO cmimedatatable(KODARTIKULLI, C1,C2, C3, C4, C5, C6) VALUES('".$x['KODARTIKULLI']."',0,0,0,0,0,".$x['CMIMI'].")"; } } $mysqli->query($query); } And this is how the data are saved in my table,
  23. My problem is that everytime when a user uploads photos through my app in openshift it gets lost.When i try to update the code through git,I couldn't find a solution on the net.So I came here for experts advice. i would also appreciate if anyone can point me to an article that does it for php app in openshift. The problem is simple my user uploaded files are stored in /user/{$_SESSION['id']} folder that is located in repo folder. through research i found that it should be stored in app-root/data folder. If so how can i store user uploaded photos directly there and access it for the user who wants to view it in browser directly like www.testing-pad4u.rhcloud.com/home.php?u={$_SESSION['name']}. i have no clue on how to do it please help me or point me in the right direction as i'm a total noob to Linux.
  24. I have 5 dropdowns on a tab of a website. I have a database table in MS SQL Server. The table has all the data of 5 dropdowns with one of the fieldNames called Region_Name, say the Region_Names are A, B, C, D, and E. I have written codes to display a table and enabled row editing for one of the RegionNames. Now, I am wondering if I could modify the same codes to display associated table with row editing enabled using different queries when a dropdown is clicked. That could reduce the code repetition and improve the performance. But I do not know how to achieve this. Could anyone please give me some hints? I am using PHP PDO to connect to the database.
  25. Trying to retrieve information from an API and display it in a table. <form action="dublinbus.php" method="get"> <h2>Current Dublin Bus Times.</h2> <b>Stop Number: </b><input type="number" name="stopid"></br></br> <input type="submit"> </form> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ <?php $stopID = $_GET['stopid']; $url = "https://data.dublinked.ie/cgi-bin/rtpi/realtimebusinformation?stopid=" . $_GET['stopid'] . "&format=json"; // Process the JSON and check for errors $json = file_get_contents($url); $array = json_decode($json,true); if ($stopID != $array["stopid"]) { // Get the values for $errorCode and $errorMessage $errorCode = $array["errorcode"]; $errorMessage = $array["errormessage"]; echo "Error: "; echo $errorCode; echo $errorMessage; } else { // Get the values $duetime = $array["duetime"]; $destination = $array["destination"]; $route = $array["route"]; echo " <table>"; echo " <th>Stop Number</th><th>Route</th><th>Due Time</th><th>Destination</th>"; echo " <tr><td>" . $stopID . "</td><td>" . $route . "</td><td>" . $duetime . "</td><td>" . $destination . "</td></tr>"; echo "</table>"; } ?>
×
×
  • 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.