Jump to content

Search the Community

Showing results for tags 'mysql'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

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


Languages

Found 261 results

  1. Hello, Please help, how to implement the Depth First Search algorithm into PHP MyQsli. I have a table: - problem - because - solution The DFS diagram I attached. thank you
  2. honkmaster

    CURDATE() not working for next month

    Hi I have a query that returns the count of entries based on CURDATE(), it works for any dat in this month (April) but does not work for next month (May). I think it is something to do with CURDATE()+3 returns 2018-04-31 which should be 2018-05-01 This Works as Date is in April SELECT COUNT(Machine) FROM production WHERE Status = 'Confirmed' AND DATE(FROM_UNIXTIME(production.Required)) = CURDATE() This does not work as in May SELECT COUNT(Machine) FROM production WHERE Status = 'Confirmed' AND DATE(FROM_UNIXTIME(production.Required)) = CURDATE()+3
  3. i want to build a bar chart with chartJS and database mysql with two different query, but bar chart not showing. can anyone help me to correct the code? this my query and javascript: <?php $a = mysqli_query("select count(a) as total1 from tbl"); $b = mysqli_query("select count(b) as total2 from tbl"); ?> <body> <div> <canvas id="chart"></canvas> </div> <script> var ctx = document.getElementById("chart"); var chartdata = { labels: 'CHART', datasets: [{ label: "A", data: [<?php while ($data1 = mysqli_fetch_array($a)) {echo '"''.$data1['total1'].'",';}?>], backgroundColor: "#000000" },{ data: [<?php while ($data2 = mysqli_fetch_array($b)) {echo '"''.$data2['total2'].'",';}?>], backgroundColor: "#ffffff" }] }; var chart = new Chart(ctx, { type: 'bar', data: chartdata }); </script> </body>
  4. jonathanpecany

    Tutorials

    Suggestion 1: I had an idea for w3school for a very long time and this idea will help people learn better and even make school suggest it more. Add in a tutorial where people will have to figure how how to fix codes like it's almost like the try-it-out but you have to go through courses and learn programming through that, almost like khan academy almost except with programming except khan academy only teaches html and not PHP. And also it wouldn't hurt to show videos of how to understand PHP more. And also how to create websites like facebook and youtube and have interactive videos as well like khan academy and those interactive videos on there was actually cool, I was amazed of how they did that when I first learned html. W3school.com actually taught me more about html and CSS more than khan academy. I just hope this forum in connecting to the website I am talking about. But w3school did have a link to this forum so I am guessing so. Suggestion 2: Also I notice some websites has custom context menus and wondering if somehow they can teach how to create that as well because I tried searching how and had to program it and I looked at other websites and it was accurate and w3school shows more accurate html and CSS. Can it be added
  5. Hallo everyone. Thanks for a great website. I have been trying for a few days to get a safe, working php form that saves input to mysql. I have looked at several examples from different websites. The problem is that the form values are being stored to the database before the form validation process is complete. I have tried wrapping the process.php code in a function and only calling the function after the validation code is done and implemented some checks in a desperate attempt to resolve the matter using some global variables and a function that checks if the validation has done their work. But even with all this.. the user input is written to the database before validation is complete. for example.. if the user inputs his name with a preceding space, and submits the form, the preceding space ends up in the database. also a user can press the submit button multiple times and with every press, the information is stored to the database.. I imagine someone could write code to click that submit button millions of times until my server storage space runs out.. Any help would be much appreciated. Thanks. Einston I only have two files.. currently: 1: index.php and 2: testreqfields.php <html> <head> <title>Registration Form</title> </head> <body> <?php $inputisgood = false; $nameisgood = false; $surnameisgood = false; $emailisgood = false; $passwordisgood = false; include "testreqfields.php"; ?> <link href = "registration.css" type = "text/css" rel = "stylesheet" /> <h2>Sign Up</h2> <form name = "form1" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method = "post" enctype = "multipart/form-data" > <div class = "container"> <div class = "form_group"> <label>First Name:</label> <input type = "text" name = "name" value = "<?php echo $name;?>" required/> <span class="error">* <?php echo $nameErr;?></span> </div> <div class = "form_group"> <label>Surname:</label> <input type = "text" name = "surname" value = "<?php echo $surname;?>" required/> <span class="error">* <?php echo $surnameErr;?></span> </div> <div class = "form_group"> <label>Email:</label> <input type = "text" name = "email" value = "<?php echo $email;?>" required/> <span class="error">* <?php echo $emailErr;?></span> </div> <div class = "form_group"> <label>Password:</label> <input type = "password" name = "pwd" value = "<?php echo $pwd;?>" required/> <span class="error">* <?php echo $pwdErr;?></span> </div> <div class = "form_group"> <label>Gender:</label> <input type="radio" name="gender" value="female">Female <input type="radio" name="gender" value="female">Male </div> <input type = "submit" name = "enq_submit" value = "Submit" /> </div> </form> </body> </html> <?php function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } function sql_process() { //reset the global variable to be sure all code run again if there are errors in input. global $inputisgood; $inputisgood = false; //establish connection $servername = "localhost"; $config = parse_ini_file('../db_credentials/config.ini'); //create the connection $conn = mysqli_connect ($servername, $config['username'], $config['password'], $config['dbname']); //check connection if (!$conn){ die('Could not connect: ' . mysqli_connect_error()); } $sql = mysqli_select_db ($conn, $config['dbname']) or die("unable to connect to database"); //process if (isset($_POST['enq_submit'])){ $reg_name = $_POST['name']; $reg_surname = $_POST['surname']; $reg_email = $_POST['email']; $reg_pwd = $_POST['pwd']; $sql = "INSERT INTO registration (reg_name, reg_surname, reg_email, reg_pwd) VALUES ('$reg_name', '$reg_surname', '$reg_email', '$reg_pwd')"; echo("You have been signed up."); if (!mysqli_query($conn,$sql)){ die('Error: ' . mysqli_error($conn)); } } else { echo("Kindly use the form to sign up:"); }; } function ready_to_process () { global $nameisgood, $surnameisgood, $emailisgood, $passwordisgood, $inputisgood; if ($nameisgood) { echo ("##Name is good"); } if ($surnameisgood) { echo ("##Surnameame is good"); } if ($emailisgood) { echo ("##Email is good"); } if ($passwordisgood) { echo ("##Password is good"); } if ($nameisgood and $surnameisgood and $emailisgood and $passwordisgood) { echo ("##All input is good!"); $inputisgood = true; $nameisgood = $surnameisgood = $emailisgood = $passwordisgood = false; } } // define variables and set to empty values $nameErr = $surnameErr = $emailErr = $pwdErr = ""; $name = $surname = $email = $pwd = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) { $nameErr = "Name is required"; } else { $name = test_input($_POST["name"]); if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $nameErr = "Only letters and spaces allowed"; } else { $nameisgood = true; } } if (empty($_POST["surname"])) { $surnameErr = "Surname is required"; } else { $surname = test_input($_POST["surname"]); if (!preg_match("/^[a-zA-Z ]*$/",$surname)) { $surnameErr = "Only letters and spaces allowed"; } else { $surnameisgood = true; } } if (empty($_POST["email"])) { $emailErr = "Email is required"; } else { $email = test_input($_POST["email"]); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $emailErr = "Invalid email format"; } else { $emailisgood = true; } } if (empty($_POST["pwd"])) { $pwdErr = "Password is required"; } else { $passwordisgood = true; } ready_to_process(); if ($inputisgood) { sql_process(); } } ?>
  6. Hi I have a question, but no real example yet. I wonder if someone can tell how to create a serial number that counts from 10000 to 100000 en divide it as a unique id over several databases and table.columns? I dont want to have an example with uniqid() , but counting up with one. I have no clue how to do this can someone please give any suggestion?
  7. BACKGROUND: i have created a search box for users to query the Grammar Captive database with Natural Language functionality. As the query string results in a single variable that is read into an AGAINST statement (see below), I am concerned about the overall safety of my database and web application. QUESTION ONE: Is it possible to write a prepared statement with the value of an AGAINST clause as an unknown? If not, what must one do in order to prevent against SQL injection? WHAT I HAVE CREATED SELECT letter_no, letter_title, letter_abstract, submission_date, revision_date, MATCH (letter_title, letter_abstract, letter_body) AGAINST ('$search_input') AS letter_score FROM sevengates_letter WHERE MATCH (letter_title, letter_abstract, letter_body) AGAINST ('$search_input') ORDER BY letter_score DESC WHAT I WANT TO CREATE SELECT letter_no, letter_title, letter_abstract, submission_date, revision_date, MATCH (letter_title, letter_abstract, letter_body) AGAINST ('$search_input') AS letter_score FROM sevengates_letter WHERE MATCH (letter_title, letter_abstract, letter_body) AGAINST (?) ORDER BY letter_score DESC QUESTION TWO: Will the "What I want to create" version fly? Roddy
  8. BrainPill

    DELETE records before specific time

    Hi. This is the table output I have while using SELECT. Now I want to DELETE all records , except those from the last 3 hours. I tried mysql combined with now() and I tried this: SELECT * FROM `my_tab` WHERE SEC_TO_TIME(-10800) > `created_on` If someone can give the right setup how to do this in PHP/MYSQL then I would be very happy.
  9. If I use the following commands: ALTER TABLE yourtab CHANGE `$colname1` `$colname2` VARCHAR(20) NOT NULL; ALTER TABLE yourtab MODIFY `$colname1` `$colname2` VARCHAR(20) NOT NULL; ALTER TABLE yourtab CHANGE COLUMN `$colname1` `$colname2` VARCHAR(20) NOT NULL; And because I use a variable inside a loop I can change an array of column names. The challenge I'm facing is that VARCHAR or other type formats are obviously obliged. is that true? Is there a possibility to change a column name and keep the type set as the original table create settings?
  10. BrainPill

    three arrays in 1 foreach loop

    I can not fix this script, because the output is not in sync. I have 3 arrays. 1) present column names. 2) prefix (fixed name). 3) suffix (uniqid value). Can someone explain how exactly I should create a foreach loop in a foreach loop with 3 arrays and fetching the field value from the get_result command as the the value it is related to. This would result in: <---->Present Column Name <-----> New Column Name <---->value1 <--------------------------------> value1_abcd <---->value2 <------------------------------> value2_abcd etc. <?php $prefix_arr = array( 'col_a' , 'col_b' ,'col_c' , 'col_d', 'col_e' , 'col_f' , 'col_g' , ) ; $col2 = uniqid(); $suffix = substr($col2, 5, 11); $servername = "localhost"; $username = "userx"; $password = "pass12345"; $dbname = "test_database"; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $stmt = $conn->prepare("SHOW COLUMNS FROM table_xyz"); $stmt->execute(); $res = $stmt->get_result(); $pres_colname = $res; // var_dump($prefix_arr); foreach ($prefix_arr as $los_ele){ $prefix = $los_ele; // var_dump($prefix); // var_dump($suffix); $col_new = $prefix."_".$suffix; //var_dump($col_new); foreach ($pres_colname as $val){ $col = $val['Field']; // var_dump($col); ?> <br><input type="text" value =" <?php echo $col; ?>"><input type="text" value ="<?php echo $col_new;?>"> <?php $stmt = $conn->prepare("ALTER TABLE `table_xyz` CHANGE COLUMN `$col` `$col_new` VARCHAR(30) NOT NULL;"); $stmt->execute(); } } //$stmt->close(); $conn->close(); ?> The complicated thing this time is that I need the exact 'Field' value which is an output of get_result, so I can not fit it in.
  11. BACKGROUND: I am in the process of writing a class that will match and update rows in a MySQL data base. The field that contains the values against which a match is to be discovered must be indefinite. The values that it can contain are either 0 or 1 as defined by an ENUM field type. I know both the desired field and value before the matching routine commences. I want the UPDATE routine to set the value of the field to its opposite: 0 => 1 or 1 => 0. CURRENT STATE OF THE CODE: <?php class VeriFirm { private $mysqli_obj; private $username; private $email; private $hash; private $action = 0; private $field; private $tbl_name = 'captive_roster'; public $link = 'admin@grammarcaptive.com'; public $subject = 'Grammar%20Captive%20-%20Verify%20and%20Confirm%20User%20Action'; public $msg_mismatch = "Sorry, " . $this->username . ", but no matching entry in the Grammar Captive database was found. Please try again! If the problem persists, contact the Grammar Captive <a class='link_style' href='" . create_link() . "' title='Grammar Captive Online Administrator' target='_top'>webmaster</a> and expect a reply in response to your additional effort!"; public $msg_success = "Congratulations, " . $this->username . ", your desired action was successfully processed. No further action is required on your part."; public $msg_failure = "Sorry, " . $this->username . ", but Grammar Captive was unable to process your desired action. It appears that your account status has already been reset. If the problem persists, please contact the Grammar Captive <a class='link_style' href='" . create_link() . "' title='Grammar Captive Online Administrator' target='_top'>webmaster</a> and expect a reply in response to your additional effort!"; function __construct($mysqli_obj, $_GET, $field) { $this->mysqli_obj = $mysqli_obj; $this->field = $field; if((isset($_GET['username']) && !empty($_GET['username'])) AND (isset($_GET['email']) && !empty($_GET['email'])) AND (isset($_GET['hash']) && !empty($_GET['hash']))){ $this->$username = $mysqli_obj->real_escape_string($_GET['name']);; $this->$email = $mysqli_obj->real_escape_string($_GET['email']); $this->$hash = $mysqli_obj->real_escape_string($_GET['hash']); $this->$action = $mysqli_obj->real_escape_string($_GET['action']); } } function create_link() { return $mailto = "mailto:" . $this->link . "?Subject=" . $this->subject; } function match_data() { $sql_select = "SELECT user_name, email_address, hash, " . $this->field . " FROM " . $this->tbl_name . " WHERE user_name=? AND email_address=? AND hash=? AND " . $this->field . "=" . $this->action; $mysqli_stmt = $this->mysqli_obj->stmt_init(); $mysqli_stmt->prepare($sql_select); $mysqli_stmt->bind_param("ssss", $this->username, $this->email, $this->hash, $this->field); $mysqli_stmt->execute(); $mysqli_result = $mysqli_stmt->get_result(); $match = mysqli_num_rows($mysqli_result); if($match > 0){ update_record(); } else { return $msg_mismatch; } } function update_record() { if ($this->action == 0) { $sql_update = "UPDATE " . $this->tbl_name . " SET " . $this->field . "='1' WHERE user_name=? AND email_address=? AND hash=? AND ". $this->field . "=0"; $mysqli_stmt->prepare($sql_update); $mysqli_stmt->bind_param("sss", $this->username, $this->email, $this->hash); if ($mysqli_stmt->execute()) { return $msg_success; } else { return $msg_failure; } } else if ($this->action == 1) { $sql_update = "UPDATE " . $this->tbl_name . " SET " . $this->field . "='0' WHERE user_name=? AND email_address=? AND hash=? AND ". $this->field . "=1"; $mysqli_stmt->prepare($sql_update); $mysqli_stmt->bind_param("sss", $this->username, $this->email, $this->hash); if ($mysqli_stmt->execute()) { return $msg_success; } else { return $msg_failure; } } function get_link_and_subject() { return $this->link . ' and ' . $this->subject; } function set_link_and_subject($link, $subject) { $this->link = $link; $this->subject = $subject; } function get_tablename() { return $this->tbl_name; } function set_tablename($tbl_name) { $this->tbl_name = $tbl_name; } function get_msg_mismatch() { return $this->msg_mismatch; } function set_msg_mismatch($msg_mismatch) { $this->msg_mismatch = $msg_mismatch; } function get_msg_success() { return $this->msg_success; } function set_msg_success($msg_success) { $this->msg_success = $msg_success; } function get_msg_failure() { return $this->msg_failure; } function set_msg_failure($msg_failure) { $this->msg_failure = $msg_failure; } } ?> I am primarily concerned about the following: if((isset($_GET['username']) && !empty($_GET['username'])) AND (isset($_GET['email']) && !empty($_GET['email'])) AND (isset($_GET['hash']) && !empty($_GET['hash']))){...} Is this a proper use of the $_GET superglobal or would a $_POST or $_REQUEST superglobal be more appropriate. I am concerned about making user's private information public. This said, all communication with the Grammar Captive website is now available to TLS/SSL protocol -- namely, the https:// prefix. $sql_select = "SELECT user_name, email_address, hash, " . $this->field . " FROM " . $this->tbl_name . " WHERE user_name=? AND email_address=? AND hash=? AND " . $this->field . "=" . $this->action; Is this statement properly specified? I am concerned about the placement of the quotation marks and the ability of the mysqli_stmt object to read properly the intended SQL statement. $mysqli_stmt = $this->mysqli_obj->stmt_init(); Is this proper use of the -> operator in the construction of a PHP Class. $sql_update = "UPDATE " . $this->tbl_name . " SET " . $this->field . "='1' WHERE user_name=? AND email_address=? AND hash=? AND ". $this->field . "=0"; Is this statement properly described? Once again, my focus is on the use of quotations marks to define the statement. update_record() Is this the most efficient way to achieve the desire goal -- namely, to toggle the value of action between 0 and 1 depending on an initially assumed value of $this->field. Roddy
  12. Notretsam

    order of matching results

    This isn't a bug or a how too inquiry, I know how to order items with mysql queries. What I am wondering though is, how does mysql determine what result goes first between 2 matching results? A quick example, I do a SQL Query ordering by "total wins", so a numeric value. 2 people have 7 wins each, how does the SQL Query determine the order for the 2 people? In my testing of leagues that am coding, I actually have two divisions of 8 people with 7 wins/ 7 losses each, always showing on leaderboard at same position. I am thinking its ordered by who was added first to database table? but am not sure if mysql has the capability to remember that? As I said, its not a bug or a big deal really, am just curious on this. I also figured I might get asked in future by someone playing my game.
  13. iwato

    SELECT JOIN - A Failed Query

    PROBLEM: Turn a two-step SELECT procedure into a one-step procedure. The two-step procedure is 1) Discover with a query to a parent table what other rows in the parent table are related to the queried row. 2) Obtain selected data for the queried row and other related rows from the parent table and a child table that are connected by a FOREIGN KEY. BACKGROUND: I have two tables -- a parent (parent_table) and a child (child_table) table - connected by a valid FOREIGN KEY and an additional table (ref_table) that contains information about the relationship among the rows of both the parent and child tables. Please find below the results of three SHOW CREATE TABLE statements to help you in your understanding of the table structure. In addition, I have included the INSERT statements for the child_table and ref-table. I accidentally destroyed the INSERT statement for the parent_table. This said, the parent and child tables are very similar in structure. DISCLAIMER: Please understand that the problem that I have created is heuristic in nature and is being used to create a prototype for subsequent, more practical use. The PARENT Table parent_table CREATE TABLE `parent_table` ( `id` int(3) NOT NULL DEFAULT '0', `usertype` enum('1','2','3') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '2' COMMENT '1=good, 2=neutral, 3=bad', `username` char(150) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id`,`usertype`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 The CHILD Table child_table CREATE TABLE `child_table` ( `id` int(3) NOT NULL DEFAULT '0', `usertype` enum('1','2','3') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '2' COMMENT '1=good, 2=neutral, 3=bad', `userbio` varchar(500) DEFAULT NULL, KEY `parent` (`id`,`usertype`), CONSTRAINT `child_table_ibfk_1` FOREIGN KEY (`id`, `usertype`) REFERENCES `parent_table` (`id`, `usertype`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=latin1 INSERT INTO `child_table` (`id`, `usertype`, `userbio`) VALUES ('1', '1', 'I am Roddy.'), ('2', '2', 'I am Beth.'), ('3', '3', 'I am Matt.'), ('4', '3', 'I am Tim.'), ('5', '2', 'I am Tylor.'), ('6', '1', 'I am Liz.'), ('7', '1', 'I am Aldo.'), ('8', '1', 'I am Adzit.'), ('9', '3', 'I am Jason.'), ('10', '3', 'I am David.') The REFERENCE Table ref_table CREATE TABLE `ref_table` ( `ref_id` int(3) NOT NULL DEFAULT '0', `id` int(3) DEFAULT NULL, `ref` int(3) DEFAULT NULL, `count_ref` int(1) DEFAULT NULL, KEY `par_ref` (`ref_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 INSERT INTO ref_table (ref_id,id,ref,count_ref) VALUES ('1','1','2','1'), ('2','1','6','2'), ('3','1','7','3'), ('4','2','6','1'), ('5','2','9','2'), ('6','4','1','1'), ('7','4','2','2'), ('8','4','6','3'), ('9','4','10','4'), ('10','5','6','1'), ('11','6','1','1'), ('12','6','2','2'), ('13','6','9','3'), ('14','7','5','1'), ('15','7','6','2'), ('16','8','1','1'), ('17','9','10','1'), ('18','10','4','1'), ('19','10','6','2'), ('20',10, NULL,'1'); EXPLANATION BY EXAMPLE: Say a user is interested in row 4 of the parent_table. When the database is queried a SELECT JOIN statement looks in the id field of the ref_table and finds four corresponding rows identified by ref_id 6, 7, 8, and 9. With each of these latter rows is associated a different row -- namely, 1, 2, 6, 10. Without further selection is returned all of the information contained in the parent_table and child_table associated with rows 1, 2, 4, 6, and 10. This is what is supposed to happen, but does not. The REJECTED SQL STATEMENT SELECT * FROM parent_table OUTER JOIN child_table ON parent_table.id = child_table.id OUTER JOIN ref_table ON parent_table.id = ref_table.id QUESTION ONE: Does the table structure make sense? Are the constraints properly set? QUESTION TWO: Why is my SQL statement rejected as poorly formatted? This is my first attempt to use the JOIN clause. So, please be as thorough with your answer as possible. I must believe that I have a long road ahead with MySQL and should prepare for it as i move forward. Roddy
  14. BrainPill

    change column names of a table

    My question is, if it is possible, to change the name of the column with MYSQL. (not with php) This is my example: mysql> select * from horses; +------------+---------------+-----------------------+---------------------+---------------------+-----------------------------+ | num | name | location | created_day | changed_day | key_value | +------------+---------------+-----------------------+---------------------+---------------------+-----------------------------+ | 1 | Horse Riding | http://www.camping.fr | 2017-03-30 13:40:16 | 2017-10-19 18:14:57 | Horse, Riding, Woods | | 2 | Horseriding77 | http://www.wine.com | 2017-10-27 10:16:59 | 2017-10-27 10:16:59 | Outdoor, Vacances, Test | | 3 | Horsetours45 | http://www.fake.com | 2017-10-23 16:18:17 | 2017-10-23 16:18:17 | Outdoor, Vacances, Test | | 4 | Horsetours57 | http://www.bing.com | 2017-10-23 17:24:32 | 2017-10-23 17:24:32 | Outdoor, Vacances, Test | | 5 | Horseriding48 | http://www.test.com | 2017-10-25 09:05:18 | 2017-10-25 09:05:18 | Outdoor, Vacances, Test | | 6 | Horseriding67 | http://www.google.uk | 2017-10-27 10:11:18 | 2017-10-27 10:11:18 | Outdoor, Vacances, Test | | 7 | Horseriding52 | http://www.google.es | 2017-10-26 17:00:05 | 2017-10-26 17:00:05 | Outdoor, Vacances, Test | | 8 | Horseriding57 | http://www.google.fr | 2017-10-27 12:13:38 | 2017-10-27 12:13:38 | Outdoor, Vacances, Test | +------------+---------------+-----------------------+---------------------+---------------------+-----------------------------+ 8 rows in set (0.03 sec) mysql> the idea is that for example location as a column name is changed by mysql into other names.
  15. thunderousity

    MySQL - Columns based on 2 Columns by Row

    I have 2 tables. A table full of items with an ID number and various values (Table A) and a table which works as the basis for an Item comparison using the ItemID's (Table B ) Table A ItemID, Item_Name, Value_1 1, Potato, 50 2, Carrot, 45 3, Broccoli, 35... Table B ComparisonID, ItemID1, ItemID2 1, 1, 3 2, 2 ,3 3, 5, 145 Requirement: I want to return the ItemID, Item Name and Value for each row in Table B like so Results: ItemID1, Item_Name, Value_1, ItemID2, Item_Name, Value_1 1, Potato, 50, 3, Broccoli, 35 2, Carrot, 45, 3, Broccoli, 35 5, Courgette, 102, 145, Banana, 274 I can create the basic MySQL to return each of the columns using a Union query. However I don't think this is the way to go. It's the part where I need to iterate through each row in Table B whilst also using separate ItemID's for separate columns from the same row that I can't get my head around. Table B will only be up to 1000 rows so it doesn't need to be too efficient. Any ideas where to start? Cheers.
  16. Hello folks, I want to hide a text inside a image(users given image using file upload). Thanks in advance
  17. iwato

    Read Multiple Rows Sequentially

    QUESTION ONE: What is it called when you traverse an entire table in equal multiples of records? (I ask this question, because I have been fraught with frustration in my google searches.) QUESTION TWO: Do you know a routine that I can copy and modify? (This would greatly simply my search.) BACKGROUND: Surely there must be a standard routine for performing the following procedure: 1) Use PHP to read and display the first ten records of a MySQL table. 2) Read and display the next ten records of the same data table. 3) Either return to the previously read ten records and display these or continue on to the following ten unread records and display them. 5) When you have reached the end of the table display only the remaining records. GOAL: Ultimately I would like to read and display 10 records in a list format. At the bottom of the list I would place two buttons. One that displays the previously 10 records and one that displays the next ten unread records. WHAT I HAVE ACHIEVED SO FAR: <?php $col_name = 'item_pubdate'; $result_obj = $mysqli_obj->query("SELECT * FROM rss2_podcast_item ORDER BY '$col_name' LIMIT 0, 10"); while($row=$result_obj->fetch_array()) { ?> <div class='table_row podcast_item'> <div class='flex_item num_div'><?php echo $row['podcast_no_item'] . '&nbsp'; ?></div> <div class='flex_item date_div'><?php echo $row['item_pubdate']; ?></div> <div class='flex_item title_div'><?php echo $row['item_title']; ?></div> </div><!-- end div.table_row --> <div class='table_row discover_div'> <div class='flex-item'>Discover more ...</div> </div><!-- end div.table_row --> <div class='table_row'> <div class='flex-item details_div'> <?php echo $row['item_description']; ?> </div><!-- end div.table_row --> </div><!-- end div.table_row --> <?php } ?> With a little additional CSS and Javascript I have been able to achieve the following display. Clicking on the phrase "Discover more ..." reveals the hidden detail obtained from $row['item_description]. No. Publication Date|Time Podcast Title 60 2017-06-19 17:26:41 Title Ten Discover more ... 59 2017-06-18 09:50:37 Title Nine Discover more ... . . . 51 2017-09-24 11:00:17 Title One Discover more ... DESIRE: If I can only achieve the above stated goal, I can likely figure out a way to get AJAX to allow users to select podcast items by the week, month, year, and later category. But, this is already much too far into the future. For the moment, I would simply like to achieve my above stated goal. Any ideas? Roddy
  18. $text = "i am a student of oxford university, and i love to tell everyone how much i have enjoyed my four years in school. the whole environment was really welcoming" . Actually, we have a database table called "text_word". So, i want a script that will search through the above text and check if any of those words from the above text does not exist in the "text_word" table, such word should be replaced by asterisks and store the replaced word into a separate column called "unmatched_word" in the same "text_word" table. let's assume the word "welcoming" was not existing in my database what i want to achieve is this. the text is parsed through the program INPUT: "i am a student of oxford university, and i love to tell everyone how much i have enjoyed my four years in school. the whole environment was really welcoming" . OUTPUT: "i am a student of oxford university, and i love to tell everyone how much i have enjoyed my four years in school. the whole environment was really ******" . Code Sample: foreach ($text as $word) { $select_word = $f->filterRecord("*", "parts_of_speech", "word", $word); $get_word = $f->show_data($select_word); $count_words = $f->numR($select_word); if ($count_words > 0) { $result[] = '<a href="word/?w='.$word.'">'.$word.'</a>'; } else { $result[] = "******"; } } Please i believe the code is not doing exactly what i want. If you have a better approach to how i can get the job done, i don't mind if you give me a fresh code snippet or script. I hope you understand what i'm trying to do now?
  19. iwato

    Unwanted Row Entry Duplication

    QUESTION ONE: How does one suppress duplicate row entries? QUESTION TWO: In the following case what is causing them to occur? BACKGROUND: I created several tables only to discover that they were not as I wanted them. AFter truncateng each, I dropped what I believed to be poorly structured columns, rearranged some, and added still others. When I tested the result, everything worked great except for one problem -- a single table entry reuslted in duplicate rows. THE TABLE STRUCTURE CREATE TABLE 'table_name' (obs` int(5) NOT NULL AUTO_INCREMENT . . . PRIMARY KEY (`obs`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 A SAMPLE SQL STATEMENT INSERT INTO rss2_podcast_itunes (podcast_no_itunes, itunes_category1, itunes_category2, itunes_category3, itunes_complete, itunes_new_feed_url, itunes_name, itunes_email, itunes_duration, itunes_order, itunes_author, itunes_block, itunes_image, itunes_explicit, itunes_summary) VALUES ('54', 'education', 'language', 'English', '', '', 'Roddy A. Stegemann', 'kiusau@me.com', '00:01:01', '', 'Roddy A. Stegemann', '', 'http://www.grammarcaptive.com/_images/captive.png', '', 'Test') Please note the following: No value is entered for the obs field/column. The auto increment advances one for each row entered. Below each successfully loaded row entry appears another row identical in every way but one -- the appearance of an incremental advance in the value of the obs field. Please advise. Roddy
  20. 1) I have login scripts working in combination with database table and verify_password 2) the login scripts are RE-USED for another site 3) In the test fase I use the SAME database table values and copy these in phpmyadmin to a new table is it possible there is some kind of copy security or whatever in the encrypted original table values? I presume this because there is no password_verify match. It could be I'm overlooking something, but the password_verify($form_pw, $database_pw) procedure, does not need encryption BEFORE $form_pw is read? The only conclusion then is: the value in the newly copied table is not the same is in the original table. (of course I can also reinstall the registration scripts to test it, but i would like to rule out other causes ) EDIT: solved. silly me using the wrong password
  21. Hey guys, I have a problem. I want to write a record in my db when it does not already exists. For this, i have been looking on the web and found multiple solutions on Stackoverflow. The one I use is proved working, by the stack user however I get my die response :(. I use the following query (mysql/php): $query= "IF NOT EXISTS (SELECT * FROM tasksmade WHERE teamnumber='$teamnumber' AND tasknumber='$tasknumber' AND date='$date') INSERT INTO tasksmade (teamnumber, tasknumber, taskfinished, date) VALUES ('$teamnumber', '$tasknumber', '$taskfinished', '$date')"; $result= mysql_query($query,$mysql) or die("The query result has failed on the db!"); Hope someone can help! Thanks!
  22. Balderick

    mysql join from 2 different databases

    Hi all, I have a question about join or inner join; not sure in what way it should be used. I now use 2 queries in 2 different databases (made in phpmyadmin). SELECT `title` FROM `writers` WHERE id ='qwert58efedd1979f'; SELECT `name`, `lastname`, `str`, `nr`,` place` FROM `client` WHERE id ='qwert58efedd1979f'; I would like to make one mysql query and use join to search in 2 tables in 2 different databases. Can anyone tell how mysql does this?
  23. Kevin Castro

    Xampp is not working

    Hello folks, I installed a XAMPP Version 7.0.15 on my windows 7(32-bit) computer but it doesn't work properly.When i open in the browser it shows "The site can't be reached". What's the solution for it? please help me. Thank you in Advance..
  24. marcodb

    Copy table from sql to mdb

    Hi, i'm new and i hope not wrong with to ask the following question: i see this instruction SELECT * INTO CustomersBackup2013 IN 'Backup.mdb' FROM Customers; in thee site, that is in a section of copy from sql (to mdb, i thougt since the db name is backup.mdb). I'm looking for the similar command for copy/create the similar command but for mysql as origin and mdb as destination. Thanks of all.
  25. darbok

    wordpress, mybbs, wiki.

    is there a way to make a singular login for a wordpress website that also logs a person into the forums and the wiki at the same time?
×