PHP - Jquery Datatable. Disable Searching In Action Column?
How do disable searching in specific column like Action col
Id--Username--Subject--Action | Do not search oTable = $('.datatable table').dataTable({ "bJQueryUI": false, "bAutoWidth": false, "sPaginationType": "full_numbers", "sDom": '<"datatable-header"fl><"datatable-scroll"t><"datatable-footer"ip>', "oLanguage": { "sSearch": "<span>Filter all:</span> _INPUT_", "sLengthMenu": "<span>Show entries:</span> _MENU_", "oPaginate": { "sFirst": "First", "sLast": "Last", "sNext": "Next", "sPrevious": "Previous" } }, "order": [], /* No initial order */ "aoColumnDefs": [{ "bSortable": false, "aTargets": ['nosort'] /* Colomn data not sortable. Use <th class="nosort"> */ }] }); Similar TutorialsHi all, iv benn search for a long time now for a sample on how to create MYSQL based data grid that have some CRUD functionality.. i am using dreamwever and the only thing i can get out of it is using the spray data set that gives me a table with sort abilities but i am looking for something more.. is there a PHP or JS sample of displying the data of MYSQL database that can can do CRUD and search abilities ? thank.. hey guys!
i'm back again with another question
I've been messing with the piece of code for a few days now and can't get it to function properly.
i'm trying to make each row a different color which works... BUT it leaves out some data and prints it double...
This is the piece of code that will help you find what i've been doing wrong...
$color="1"; while($row = mysqli_fetch_array($retval, MYSQLI_ASSOC)) { if($color==1){ $cardname = $row['Name']; $encodedcardname = str_replace(" ","%20",trim($cardname)); $url = "http://mtgimage.com/card/$encodedcardname.jpg"; echo "<tr bgcolor=''><td>"; echo "<a href=$url>$cardname</a>"; echo "</td><td>"; echo $row['Color']; echo "</td><td>"; echo $row['Type']; echo "</td><td>"; echo $row['Subtype']; echo "</td><td>"; echo $row['Power']; echo "</td><td>"; echo $row['Toughness']; echo "</td><td>"; echo $row['Manacost']; echo "</td><td>"; echo $row['Rarity']; echo "</td><td>"; echo $row['Expansion']; echo "</td><td>"; echo $row['Foil']; echo "</td><td>"; echo $row['Stock']; echo "</td></tr>"; $color="2"; } else { echo "<tr bgcolor='#F8F8F8'><td>"; echo "<a href=$url>$cardname</a>"; echo "</td><td>"; echo $row['Color']; echo "</td><td>"; echo $row['Type']; echo "</td><td>"; echo $row['Subtype']; echo "</td><td>"; echo $row['Power']; echo "</td><td>"; echo $row['Toughness']; echo "</td><td>"; echo $row['Manacost']; echo "</td><td>"; echo $row['Rarity']; echo "</td><td>"; echo $row['Expansion']; echo "</td><td>"; echo $row['Foil']; echo "</td><td>"; echo $row['Stock']; echo "</td></tr>"; $color="1"; } } echo "</table>";A picture of the result of whats it outputting right now is attached to this thread. Thanks in advance! Attached Files Naamloos.png 322.6KB 0 downloads It give an the link like
http://localhost/aps/undefined
Object not found! The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error. If you think this is a server error, please contact the webmaster. Error 404 localhost Apache/2.4.35 (Win32) OpenSSL/1.1.0i PHP/7.2.11 //The php code to fetch data
//The php code to fetch data <?php include('db.php'); $query = ''; $output = array(); $query .= "SELECT * FROM users "; if(isset($_POST["search"]["value"])) { $query .= 'WHERE first_name LIKE "%'.$_POST["search"]["value"].'%" '; $query .= 'OR last_name LIKE "%'.$_POST["search"]["value"].'%" '; } if(isset($_POST["order"])) { $query .= 'ORDER BY '.$_POST['order']['0']['column'].' '.$_POST['order']['0']['dir'].' '; } else { $query .= 'ORDER BY id DESC '; } if($_POST["length"] != -1) { $query .= 'LIMIT ' . $_POST['start'] . ', ' . $_POST['length']; } $statement = $connection->prepare($query); $statement->execute(); $result = $statement->fetchAll(); $data = array(); $filtered_rows = $statement->rowCount(); foreach($result as $row) { $sub_array = array(); $sub_array[] = $row["first_name"]; $sub_array[] = $row["last_name"]; $sub_array[] = '<button type="button" name="update" id="'.$row["id"].'" class="btn btn-warning btn-xs update">Update</button>'; $sub_array[] = '<button type="button" name="delete" id="'.$row["id"].'" class="btn btn-danger btn-xs delete">Delete</button>'; $data[] = $sub_array; } $output = array( "draw" => intval($_POST["draw"]), "recordsTotal" => $filtered_rows, "recordsFiltered" => get_total_all_records(), "data" => $data ); echo json_encode($output); ?> //javasrcipt jquery var dataTable = $('#user_data').DataTable({ "processing":true, "serverSide":true, "order":[], "ajax":{ url:"fetch.php", type:"POST" }, "columnDefs":[ { "targets":[0, 3, 4], "orderable":false, }, ] });
//please dont talk about sql injection, i'll work on it, the problem with this code, it count all entries in a database table but i wantto count only with nid = 1 $query = 'SELECT * FROM abc WHERE nid = if(!empty($_POST["search"]["value"])){ $query .= 'AND (a LIKE "%'.$_POST["search"]["value"].'%" OR b LIKE "%'.$_POST["search"]["value"].'%" OR c LIKE "%'.$_POST["search"]["value"].'%") '; } if(!empty($_POST["order"])){ $query .= 'ORDER BY '.$_POST['order']['0']['column'].' '.$_POST['order']['0']['dir'].' '; } else { $query .= 'ORDER BY id DESC '; } if($_POST["length"] != -1){ $query .= 'LIMIT ' . $_POST['start'] . ', ' . $_POST['length']; } $result = mysqli_query(dbConnect, $query);
My Php Buddies, I have mysql tbl columns these:
id: Now, I want to display their row data by excluded a few columns. Want to exclude these columns: date_&_time account_activation_code account_activation_status id_verification_video_file_url password
So, the User's (eg. your's) homepage inside his account should display labels like these where labels match the column names but the underscores are removed and each words' first chars CAPITALISED:
Id: 1
For your convenience only PART 1 works. Need help on Part 2 My attempted code:
PART 1 <?php // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // Query to get columns from table $query = $conn->query("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'members' AND TABLE_NAME = 'users'"); while($row = $query->fetch_assoc()){ $result[] = $row; } // Array of all column names $columnArr = array_column($result, 'COLUMN_NAME'); foreach ($columnArr as $value) { echo "<b>$value</b>: ";?><br><?php } ?> PART 2 <?php //Display User Account Details echo "<h3>User: <a href=\"user.php?user=$user\">$user</a> Details</h3>";?><br> <?php $excluded_columns = array("date_&_time","account_activation_code","account_activation_status","id_verification_video_file_url","password"); foreach ($excluded_columns as $value2) { echo "Excluded Column: <b>$value2</b><br>"; } foreach ($columnArr as $value) { if($value != "$value2") { $label = str_replace("_"," ","$value"); $label = ucwords("$label"); //echo "<b>$label</b>: "; echo "$_SESSION[$value]";?><br><?php echo "<b>$label</b>: "; echo "${$value}";?><br><?php } } ?> PROBLEM: Columns from the excluded list still get displayed. Edited November 19, 2018 by phpsaneHi I am building a class to manage site users (Via a CMS). In order to complete this I am building a delete/remove user function/method. Things are going ok (I think), but I am confused about what to put in the action tag of the form being used to process the data. Before coding my method, I referred to a script that someone showed me which does something similar in functionality: it deletes photos previously uploaded to a folder, and also removes the associated information from the database. I used this script as the framework for the code that I am working with. Eveything seems to be working fine - EXCEPT - when I click on the 'delete users' button, nothing happens. The first thing that I examined for error was the action attribute within my form. The value of the action attribute is: action = "<? php htmlentities($_SERVER["PHP_SELF"]) ?>" This format has worked for previous forms. I compared this to the action attribute within the script that I was using as a guide. It's value is set as follows: action = "remove_photo.php?<?php echo "action='godel' ";?> In this instance, remove_photo.php is the file that is being used to both process and display the form. The reference script works perfectly but it uses a procedural approach . For my application, I am using a more object oriented approach, so both my opening and closing form tag elements are stored in a seperate file to the class file that processes it. I am new to OO but relatively comfortable with the paradigm so far (my other methods etc are working fine). I therefore suspect that the reason for my script's inability to process is due to the action attribute setting (I cannot be 100% sure of course!). I am going to therefore apply the action attribute settings used successfully in the reference script, to the application that I am building. However, the trouble is, I don't understand it I don't like it when something works, but I can't see the logic behind why it does. I am not concerned about the form id or method attrbutes. I understand what is going on there - and why they are set as they are. However, the action attribute is very difficult to understand for the following reasons: 1/ There is no variable/method/entity/object/ANYTHING called 'godel' elsewhere in the reference script. For this reason I thought that it might not be needed, so removed the bit of code within PHP tags concerning it: <?php echo "action='godel' ";?> - When I did this - the script didn't work. In fact - nothing at all would process. This was a similar result to what was happening with the script I am building. 2/ I then put the PHP line back in, but replaced 'godel' with 'something'. I saved and processed the form. - it worked. 3/ I then tried it again replacing 'godel' with an empty string i.e: ' '. - it worked. Has anyone come across forms being processed in a similar way before? If so, please could you explain what is happening here. I can't find anything relating to this type of occurence online.... I am going to place the php tags in the file I am building, to see if it has the desired effect. If it does, I will obviously keep it. But not understanding what is happening, or why it is happening is very annoying!! Thanks Hi, I want to create a search which uses the 'title' of my 'product' table and matches the terms the user has submitted. At the moment, my products are displaying one by one. For example, I have an apple and apricot in my table. The user searches 'a' and the search results show 'apple' but not apricot. Here's my code: Code: [Select] <?php require_once('inc/global.inc.php'); # search.inc.php /* * This is the search content module. * This page is included by index.php. * This page expects to receive $_GET['terms']. */ // Redirect if this page was accessed directly: if (!defined('BASE_URL')) { // Need the BASE_URL, defined in the config file: require_once ('../includes/config.inc.php'); // Redirect to the index page: $url = BASE_URL . 'index.php?p=search'; // Pass along search terms? if (isset($_GET['terms'])) { $url .= '&terms=' . urlencode($_GET['terms']); } header ("Location: $url"); exit; } // End of defined() IF. // Print a caption: echo '<h2>Search Results</h2>'; // Display the search results if the form // has been submitted. if (isset($_GET['terms']) && ($_GET['terms'] != 'Search...') ) { $terms = $_GET['terms']; $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die *('Error connecting to MySQL server'); // Query the database. $query = "SELECT * FROM product WHERE title LIKE '%$terms%'"; $result = mysqli_query($dbc, $query); // Fetch the results. $row = mysqli_fetch_array($result); // Print the results: $output[] = '<ul>'; $output[] = '<li>'.$row['title'] .': £'.$row['price'].'<br /><img src="'.$row['img'].'" alt="'.$row['title'].'" /></li>'; $output[] = '</ul>'; echo join('',$output); } else { // Tell them to use the search form. echo '<p class="error">Please use the search form at the top of the window to search this site.</p>'; } ?> A friend told me I need to use a for-each loop but I can't figure it out. Any help is appreciated, thanks for reading. I've been reading a few tutorials on how the best way to search key words in a database and at the moment im trying to get this query to work but its coming back with a error:
#1191 - Can't find FULLTEXT index matching the column listquery: SELECT title, description FROM items WHERE MATCH(title, description) AGAINST('xbox')any help or advise on how the best way to search 2 columns on matching words...thank you I'm having some trouble with a GET search code; everything works until the stringresult but then it dies to Error Querying Database Code: [Select] <html> <body> <?php //Get sort setting and search terms from URL with GET $usersearch = $_GET['usersearch']; echo 'Search word: ' . $usersearch; echo '<br>'; require_once("dbvars.php"); //Connect to Database $dbc = mysqli_connect (DB_HOST, DB_USER, DB_PW, DB_NAME) or die ("Error connecting to database."); //Build the Query $query = "SELECT * FROM customers" . 'WHERE customers.given_name=\'' . $usersearch . '\''; echo $query; //Execute the Query $result = mysqli_query($dbc, $query) or die ("Error querying database."); //Create the Table Headings echo '<table border="1"><tr>'; echo '<td><b>First Name</b></td>'; echo '<td><b>Last Name</b></td>'; echo '<td><b>Address</b></td>'; echo '<td><b>City</b></td>'; echo '<td><b>Province</b></td>'; echo '<td><b>Postal Code</b></td>'; echo '<td><b>Phone Number</b></td>'; echo '</tr>'; //Display Results through Array Loop While ($row = mysqli_fetch_array($result)) { echo '<tr><td>' . $row['given_name'] . '</td>'; echo '<td>' . $row['surname'] . '</td>'; echo '<td>' . $row['address'] . '</td>'; echo '<td>' . $row['city'] . '</td>'; echo '<td>' . $row['province'] . '</td>'; echo '<td>' . $row['postal_code'] . '</td>'; echo '<td>' . $row['phone_number'] . '</td></tr>'; } '</table>'; // Close the database connection mysqli_close($dbc); ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get"> <input name="usersearch" type="text" size="30" /> <input name="submit" type="submit" value="go" /> </form> </body> </html> Ok I have a set of PDF files that i need to be searchable. My question how do i go about doing this. Can this be achieved with php or do a need to do something else? So I've full text indexed the columns I want searchable: I have some rows inserted: Yet when I run a match() against(), I get 0 results: If I do: Code: [Select] SELECT * FROM video WHERE MATCH (name) AGAINST ('test') I get 2 results. Why does that work, yet keywords don't? Hi im really confused and annoyed Im making a real estate website and im stuck ont eh searching for a house part. Im trying to set up some searches on the different parts of the house usign text boxes for area and postcode and drop boxes for type and bedrooms and bathrooms i now you have to set up a form with input type text and then call it a name use get/post on a php side and then $_POST['search']; But i dnt seem to be able to make a search was hoping someone was kind enough to knock me up some quick code so it is functional and makbe i can work from it A;so any help towards searching using dropboxes would be awsume and if i have 2 boxes for price upper and lower how would this work Much appreciated I know that PHP is server-side, but I wondered whether anyone had a similar issue that they got around... here's my problem... I've made a psycho-analysis tool for Facebook where it runs your Facebook friends through a database of words to get their psychological preferences (that all works)... I then have a link so that users can tell their friends about the service (it's free, so I want to get it to spread virally) but I'm having a few issues with the link... At the moment, it all works from a Facebook point of view, but when they click on the link, it takes them to an almost-blank page with a bit of code on it. I know what this code is and why it's there, but I'd like to hide it behind a branded page, ideally with Ajax. When I tried to use Ajax for it, it wouldn't accept the URL that was sent. The link has to have a URL sent to Facebook like this: Code: [Select] https://graph.facebook.com/feed?access_token=149324721793321|HarGd6ioqoroENE9gv2758rfeYY&message=I%27ve+just+psycho-analysed+my+Facebook+friends+using+Manteya%27s+Facebook+Friend+Checker+%28http%3A%2F%2Fwww.manteya.com%2Ffacebook-friend-checker%29+so+that+I+can+communicate+better+with+you.&id=100001925276042 but for obvious reasons, you can't post it as an Ajax variable by using the: Code: [Select] http://www.url.com/test.php?id=$variable; Is there a way I can get around the problem? I guess the issue is that Facebook needs the detail in the URL, but PHP won't let me send it like this. I have thought about uploading the URL to a database and shortening the URL, then posting that, which would then re-direct, but that's a messy way around I'm sure you smart people have done something like this before. To see my existing (almost) working example, visit http://www.manteya.com/ffc Thanks, Neil Hello everyone from a php newbie, I have a option selections box and need to select an action depending on the results. Its for an insert script for items into a Database and depending on the chosen option it add the picture to the DB table The selection options are <select name="extension" style="font-size:18px"><option value="pdf">PDF</option><option value="zip">ZIP</option><option value="powerpoint">PowerPoint</option></select> the Swtich is switch $_POST['extention']{ case 'zip': echo $insert_image = $_POST['extension'].'winzip.gif'; break; case 'powerpoint': echo $insert_image = $_POST['extension'].'ppt.gif'; break; default: echo $insert_image = $_POST['extension'].'products/pdf.gif'; } Would someone please tell me if this is correct syntax? Or have i got it horribly wrong! Thank you for your a help Charlie I have an action that will take a long time to finish, so how can I run this action in background? So I will not have to wait it ends... When I click the save changes button, I want the user to be brought back to profile.php. Right now they are being brought to editprofile.php. I currently have the form action set to editprofile.php . When the I change it to profile.php my fields won't update. Any thoughts as to where I went wrong? Here is the editprofile.php code. <form action='editprofile.php' method="POST" id="form"> echo(" <form method = \"get\" action = \"DeleteApp.php?pname=\" . $Applications['Name'] . \"> <input value='Delete' type='submit' /> </form> "); Why is this redirecting to: DeleteApp.php?. Instead of what you can obviously see what it's supposed to redirect to. Hi everyone I am trying to pass a php variable ($R1 = 1) in to action script flash 8. After this variable is in flash 8 I want the action script to do a if statement that says if the php variable is = 1 then display layer or object. However i am not sure how to do this any help would be great thanks Freid001 PS if this is not possible to do with php and action script please say thanks im making this tool to clean up some data from a sql database, i made a php code to list what i need, thats player name,lvl and id from table_A, the problem is i want to delete from table_A and from table_B all the results from php code , they have in common the id and as a condition the lvl must be lower then 10, it seems i cant make it delete from table_B also,please help me!! a button of the end of the page to delete all that includes same id from both tables is what im looking for! Code: [Select] <table<?php echo $tableSet; ?>> <tr> <td width="*" align="center">Rank</td> <td width="*" align="center"><font color="#000000">Name</td> <td width="*" align="center"><font color="#000000">money</td> <td width="*" align="center"><font color="#000000">id</td> <td width="*" align="center"><font color="#000000">lvl</td> </tr> <?php $rank = mysql_query('SELECT name,money,id,level FROM table_A WHERE level < 10 ' .' ORDER by level desc LIMIT '.$limit.';'); $i=1; while ($row = mysql_fetch_array($rank)) { echo '<tr><td align="center">'.$i.'.</td> <td align="center"><font color="#0000FF">'.$row['name'].'</td> <td align="center"><font color="#0000FF">'.$row['money'].'</td> <td align="center"><font color="#0000FF">'.$row['id'].'</td> <td align="center"><font color="#FF0000">'.$row['level'].'</td> </tr> '; $i++; } ?>this is showing which player names goes to id(from table_A) i need to delete from table_a where the ids shown are lower then lvl 10(the ones result from code above) and same ids from table_b (the rank is just to show me ho is highest lvl) I don't mean to bother you with silly questions, but I must be using the wrong search terms to find any viable answers to this. Hypothetical situation: I have a table [Customers] with with an auto-increment id, customer_name and email generated from a form. Now, I decide to expand my database to include customer-address and telephone number. I decide to create a second table named Contactinfo for this purpose (assuming this is a better database practice). As Customerinfo is generated, I want it to POST in association with the respective customer (assuming that 'id' is the best field for association). I need some examples and best practices to accomplish this. Examples, links, or preferred terminology would be great so I can attack this phase. Thanks. |