Jump to content

Search the Community

Showing results for tags 'mysql'.

  • 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. Hello! I have little problem with my code.. and my head blow up... Code is php <?php include 'db.php'; if( isset($_POST['oak']) ){ $alltree = $_POST['alltree']; $oak= $_POST['oak']; $sql = "UPDATE users SET $puud = $puud + 1, $sirel=$sirel+1"; } if (mysqli_query($sql)) { echo "'+1 Oak tree added!"; } ?> <form action="demo.php" method="post"> <input type="submit" name="oak" value="Cut a tree!"> </form> My vision is.. if press CUT A TREE! and page updated.. and update my oak amount at mysql data.. So, i'm newbie but i take a little journey for study :)
  2. Hi guys, I'm starting to get back into coding for a hobby and wondering is there a better way of doing these php and mysql calls? they all work but not sure if it was the efficent way or is there others that everyone else uses? //connection for user details lookup $sql0 = "SELECT uid, fullname, emailaddress, created_at FROM MK_users WHERE uid={$_SESSION['id']}"; $result0 = $conn->query($sql0); //connection for user against role acceess $sql2 = "SELECT role_uid, role_bid, role_access, access_created_at FROM MK_role_access WHERE role_uid={$_SESSION['id']}"; $result2 = $conn->query($sql2); while($row2 = $result2->fetch_assoc()) { $_SESSION['role_bid'] = $row2["role_bid"]; } //connection for role access against business lookup $sql3 = "SELECT businessname, account_type, website, main_address, logo FROM MK_baccounts WHERE bid={$_SESSION['role_bid']}"; $result3 = $conn->query($sql3); while($row3 = $result3->fetch_assoc()) { $_SESSION['businessname'] = $row3["businessname"]; }
  3. Hi there, So the below code is working for 1 entry, however there is 2 entries in the database which are different postcodes and I cannot get to show in Google Maps. When I do it without Mysql and just do it direct it works, but really want to do it from MYSQL - both postcodes are valid and tested as well. <?php $sql4 = "SELECT * FROM MK_migration_details"; $result4 = $conn->query($sql4); ?> function initialize() { geocoder = new google.maps.Geocoder(); var latlng = new google.maps.LatLng(40.768505,-111.853244); var myOptions = { mapTypeControl: false, fullscreenControlOptions: false, zoom: 8, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); <?php while($row4 = $result4->fetch_assoc()) { $mig_postcode = $row4["postcode"]; } echo 'addPostCode("'.$mig_postcode.'")'; ?> } I know the issue lies with the PHP / Mysql Loop and the Javascript element 'addpostcode' when I put into the loop does not work, but works for a single address outside the loop. Really appreciate your help guys! Thanks you
  4. Hi all, I find myself in need again on PHP coding and the support last time was outstanding (no creeping here) so I am trying my luck again! I am trying to use a HREF link (lots of individual ones) to search a Mysql database and return the results in a PHP page. Example of HREF links on the page are here: https://flighteducation.co.uk/Create.html and in theory you click a career and it 'gets' and 'shows' the data from the database here: https://flighteducation.co.uk/Careers.php so, you click the 'Animator' link ->it goes to my database and drags back all the data to the Careers.php page So far this is what I have managed to not get right: HTML (screen shot added/attached Links.png) <a href="Careers Results.php?jobTitle=Animator"> PHP $id = $_GET['jobTitle']; if( (int)$id == $id && (int)$id > 0 ) { $link = mysqli_connect('localhost','MYUSERNAME','MYPASSWORD','MYDATABASE'); // Connect to Database if (!$link) { die('Could not connect: ' . mysqli_connect_error()); } $sql='SELECT * FROM careers WHERE jobTitle=' .$id; $result = mysqli_query($link,$sql); $row = mysqli_fetch_array($result); echo $row['jobTitle']; echo $row['jobDescription']; } else { echo "Record NOT FOUND"; } Up to now the code returns "Record NOT FOUND" so it is passing through the php to the end. I am new to PHP and trying to get my head around it all, and in theory this is the kind php code that I should be looking at, but I am still very new to it!! Any help or advice very much appreciated again!!! Thanks
  5. I have become able to display due data in due column but the same value is showing for each customer - what is the wrong I am doing? Here is the code, please somebody help! while ($row_custact = mysqli_fetch_assoc($query_custact)){ $currentuser = $row_custact['cust_id']; $sql_inccur ="SELECT i.inc_date, t.inctype_type, i.inc_amount, i.inc_text, c.cust_no, c.cust_name, i.inc_receipt From customer AS c LEFT JOIN incomes AS i ON c.cust_id = i.cust_id LEFT JOIN inctype AS t ON i.inctype_id = t.inctype_id WHERE c.cust_id = '$currentuser' ORDER BY inc_date DESC"; $query_inccur = mysqli_query($db_link, $sql_inccur); checkSQL($db_link, $query_inccur); while ($row_inccur = mysqli_fetch_assoc($query_inccur)){ $inc_amount = $row_inccur['inc_amount']; $inc_text = $row_inccur['inc_text']; //Iterate over income types and add matching incomes to $total $total_row = $total_row + $row_inccur['inc_amount']; $total_paid = $total_paid + $total_row; // part for total due finding.. and "inc_text" is due column $total_row_due = $total_row_due + $row_inccur['inc_text']; $total_due = $total_due + $total_row_due; // this part gathers only total due paied for an account if($row_inccur['inctype_type']=='Duepay') { $total_duepay = $total_duepay + $row_inccur['inc_amount']; } $remaining_due = $total_row_due - $total_duepay; //echo $remaining_due; } //echo $currentuser; echo '<tr> <td> <a href="customer.php?cust='.$row_custact['cust_id'].'">'.$row_custact['cust_no'].'</a> </td> <td>'.$row_custact['cust_name'].'</td> <td>'.$row_custact['custsex_name'].'</td> <td> '.$remaining_due. ' // showing due left, here is the problem </td> <td>'.$row_custact['cust_address'].'</td> <td>'.$row_custact['cust_phone'].'</td> <td>'.date("d.m.Y",$row_custact['cust_since']).'</td> </tr>'; }
  6. I’m trying to create a trigger that does two things, first take an ip that’s in dot notation and run inet_aton on it and put the result in another field. Second, checks a lookup table to identify an ip range that the result of the first action falls into and enters the id of that row in the table. This is on a mysql database on my web host. Here’s what I’ve tried: DELIMITER // CREATE TRIGGER before_ins_download BEFORE INSERT ON download FOR EACH ROW begin set new.ip_address = inet_aton(new.`ADDRESS`), new.refer=(select `id` from `ip_lookup` as i where new.ip_address between i.start and i.end limit 1 ); END; // DELIMITER ; It works without the new.refer part but after I added that it just seems to hang and never gets to the closing DELIMITER; . All ip columns are indexed. Does anyone see a mistake in my code? Thanks for looking.
  7. When I run either the inet_aton or inet6_aton command on my local mysql server (Server version: 5.7.30-0ubuntu0.18.04.1 (Ubuntu)) I get the following error: mysql> UPDATE download SET ip_address = inet6_aton(ADDRESS); ERROR 1411 (HY000): Incorrect string value: '`test`.`download`.`ADDRESS`' for function inet6_aton When I run the same command on my web host there's no problem. Both have exactly the same table structure and data. The data on the local server was imported from an export of the data on my web host. In both cases, the ADDRESS field is a varbinary(32). I've tried changing the local server to varbinary(16) and re-importing the data but got the same results. I've also restarted the mysql service but it made no difference. Can someone please explain what is going on?
  8. I'm new to using triggers and really not sure how to proceed. I have an access table that a row is inserted whenever someone opens the website or downloads a file with the following structure: `ID` int(5) NOT NULL autoincrement, `LOG_TIME` datetime NOT NULL DEFAULT current_timestamp(), `IP_ADDRESS` int(64) unsigned COLLATE utf8_general_mysql500_ci NOT NULL, `FILENAME` varchar(50) COLLATE utf8_general_mysql500_ci DEFAULT NULL, `country` varchar(50) COLLATE utf8_general_mysql500_ci DEFAULT NULL, `area` varchar(50) COLLATE utf8_general_mysql500_ci DEFAULT NULL, `city` varchar(50) COLLATE utf8_general_mysql500_ci DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_mysql500_ci; When the site is accessed, a row is inserted with only the first 3 fields are filled. When a file is downloaded another row is inserted with the first 4 fields filled. I want to create a trigger such that when a download row is inserted, the IP_ADDRESS is compared to another table to update the country, area, and city fields. I can currently do that for the whole table in mysql shell using the following code: UPDATE access t2, ip_lookup t1 SET t2.country = t1.country, t2.area = t1.area, t2.city = t1.city WHERE ((t2.IP_ADDRESS) BETWEEN (t1.start_ip) AND (t1.end_ip)) AND t2.FILENAME is not null and t2.country is null; How would I write an "after insert" trigger to update the last 3 fields based on the ip of the row that was inserted because of a download? Thanks in advance, Larry
  9. The following code is showing my result horizontally and I want to show them vertically $id = $_GET['id']; $sql = "SELECT * FROM users WHERE id = $id"; $result = $conn->query($sql); if ($result->num_rows > 0) { echo "<table align=\"center\">; <tr> <th>ID</th> <th>First Name</th> <th>Last Name</th> <th>Email</th> <th>Join Date</th> </tr>"; // output data of each row while($row = $result->fetch_assoc()) { echo "<tr> <td>".$row["id"]."</td> <td>".$row["fname"]."</td> <td>".$row["lname"]."</td> <td>".$row["email"]."</td> <td>".$row["reg_date"]."</td> </tr>"; } echo "</table>"; } Any idea? Thanks in advance
  10. I am trying to add a bootstrap class to php echo in mysql query but it doesn't work Here the code that I using $result = $conn->query($sql); echo ""; echo " New Users "; echo " "; echo ""; Any ides ?
  11. I am new in PHP Programming , Please Help me. I have made a data table, then i have connected this table after that I have made a table in my index.php file . but i am facing problem to show data from data table in my index.php file, can you help me to solve this problem? <?php include "db.php"; ?> <!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> <title>Post Global Variable</title> </head> <body> <div class="row p-5"> <table class="table table-dark"> <thead> <tr> <th scope="col">#</th> <th scope="col">Name</th> <th scope="col">User Name</th> <th scope="col">Email Address</th> <th scope="col">Password</th> <th scope="col">Phone</th> <th scope="col">Join Date</th> <th scope="col">Action</th> </tr> </thead> <tbody> <?php $myQuery = "SELECT * FROM users"; $allUsers = mysqli_query ($db, $myQuery); while ($row = mysqli_fetch_assoc($allUsers)){ $id= $row['id']; $name= $row['name']; $userName= $row['userName']; $email= $row['email']; $password= $row['password']; $phone= $row['phone']; $join_date= $row['join_date']; ?> <tr> <th scope="row"><?php echo $id; ?></th> <td><?php echo $name; ?></td> <td><?php echo $userName; ?></td> <td><?php echo $email; ?></td> <td><?php echo $password; ?></td> <td><?php echo $phone; ?></td> <td><?php echo $join_date; ?></td> <td><a class="btn btn-success btn-sm" href="#" role="button">Update</a> <a class="btn btn-danger btn-sm" href="#" role="button">Delete</a> </td> </tr> <?php } ?> </tbody> </table> </div> <!-- Optional JavaScript --> <!-- jQuery first, then Popper.js, then Bootstrap JS --> <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script> </body> </html>
  12. wrote a stored procedure this morning and i don’t know how to get the values out of it through a class function in php or phpmyadmin. here is what i wrote : public function totalProcedures($friend_name,$session_id) { /* *query to fetch stored procedure */ try { //executing the stored procedure $sql_sp="CALL timeline (:friend, :session,@updates, @group_posts)"; $stmt_sp= $this->_db->prepare($sql_sp); $stmt_sp->bindValue(":friend",$friend_name); $stmt_sp->bindValue(":session",$session_id); $stmt_sp->execute(); $rows=$stmt_sp->fetch(PDO::FETCH_ASSOC); $stmt_sp->closeCursor(); // closing the stored procedure //trying to get values from OUT parameters. $stmt_sp_2=$this->_db->prepare("select @updates,@group_posts"); $stmt_sp_2->execute(); return $stmt_sp_2->fetch(PDO::FETCH_ASSOC); } catch (PDOException $ei) { echo $ei->getMessage(); } } can someone helpme how to get results. here is the storedprocedure: DELIMITER $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `timeline`(IN `friend` VARCHAR(255), IN `session_id` VARCHAR(255), OUT `updates` VARCHAR(62555), OUT `group_posts` VARCHAR(62555)) BEGIN select * FROM updates where author in (friend,session_id) order by time desc limit 5; select * FROM group_posts where author_gp in (friend,session_id) order by pdate desc limit 5; END$$ DELIMITER ; i get the result in php myadmin as follows: how do i do this inside a php class function. CALL timeline('shan2batman','aboutthecreator', @updates, @group_posts);
  13. So I have a database that is structured like this: https://imgur.com/a/DdyTqiE Sample data: https://imgur.com/a/kYwmuO1 For each appointment, a student can have multiple categories, such as 'Academic Probation, Re-Admit' etc... I would like to loop through this table, and get a count of how many were 'is_no_show' and 'is_cancelled' per (unique) category with respect to 'scheduled_student_services.' For example, in the sample data, we see that the first appointment has 4 categories (Academic Probation, Entering Cohort Year 20051, First Generation, and Re-Admit'). Now one of these categories - Academic Probation matches up with what they were scheduled for - '1st Term Probation Advising'. And they cancelled this appointment, so we want the count of cancellations under Academic Probation to go up by 1. How would I approach this? I know I probably need to do two loops but I'm not sure the PHP syntax for this. Any suggestions or tips would be helpful. Thank you for your time!
  14. Hi, I have created a quiz and the questions get read from a MySql database table. I am now wanting to stop it repeating questions, when I first started this I thougt it would be easy just create a column called Duplicate and everytime a question got pulled I would mark it in the databse. So it would only read questions that had a "0" in the DuplicateCol and after reading the question it would put a "1" in place of the "0" That would work, the problem being multiple people are using it so if a 1 is there they wont all get asked the question. Anyway that idea is a fail now, which is a shame because everything else worked. Im hoping someone can show me another way on stopping duplicates. when I created the quiz I created a registration, and login page which have there own table I then created another table for the questions with multiple columns ie " id, Question, Answer1, Answer2, Answer3, CorrectAnswer, DuplicateCol " I had a number on my form which is a random number that lets say is "6" will then pull the question from column id 6 Query = "select Question,Answer1,Answer2,Answer3,CorrectAnswer,DuplicateCol from Questions where DuplicateCol= '0' AND id='" + RandomN.Text + "'" Anyway im for the time being lost until someone can give me ideas please, The registration, login table looks like this id, Serial, Email, UserName, Location, UserScore, Activated, I was thinking of adding q1, q2, q3, q4, q5, etc etc and then somehow if a question got pulled in my questions table with id "6" then put a "1" in the column but I think it might be to hard to try and cross reference 2 tables. Any Ideas ?
  15. Hi, I have a MySql query which currently looks like this Query = "select Question,Answer1,Answer2,Answer3,CorrectAnswer,id,Duplicate from Questions where id='" + RandomN.Text + "'" As you can see I have a table called 'Questions' which has several columns, Im using VB.NET I also have a textBox on a windows form called 'RandomN' What this does is it takes whatever number is in my textBox called RandomN.Text and looks for that number in the id column and returns all data on that row. What I am trying to acheive now is this, I have a column called Duplicate it will either contain the word 'True' or 'False' I would like it to only return data from the given number in the textBox if the Duplicate column in that row contains the word 'False' If someone can shed some light I would be greatful. Thanks
  16. Hello Everyone - I am playing around with some MYSQL and PHP project I have. I ran into a complex problem getting a PHP table filled with data from MYSQL. I will try to explain what I am trying to do: I am trying to do something like this but in PHP. This is my data from MYSQL database. The Table is called Children This is a quick explanation of how each column on the first screenshot should be filled from the database. This code is what I have so far... to be honest i am not sure how to get the totals of rest of the columns. Maybe use I can use subqueries or if statements... not sure! Can you please help me out? $r = mysqli_query($dbc,"SELECT Classrooms.ClassroomName, COUNT(*) AS TotalChildren FROM Children JOIN Classrooms ON Children.classroomID = Classrooms.classroomID GROUP BY Classrooms.ClassroomName");
  17. I'm a newbie, can you please help? I'm getting a mysql error "Unknown column 'E0000001' in 'where clause'" The id is in the URL: ...user-profile.php?id=E0000001 My Query $query = mysqli_query($con, "SELECT * FROM UserList WHERE UserID=".$id) or die (mysqli_error($con)); Thank you
  18. I am trying to centralize my database communicatin into a class (im getting tired of typing and retyping the code to send queries) Its not done but I cant get INSERT to work. Heres my Class: <?php ###################################################### # Class Name: DBConnect # Description: Base Class to handle DB inquiries # Created: 06/27/19 # Updated: 06/27/19 # Author: James 'Karæthon' Cantando # Contact: TheKaraethon@gmail.com ###################################################### class DBConnect{ ###################################################### # PROPERTIES ###################################################### # PRIVATE private const HOST = 'localhost'; private const USER = 'root'; private const PASS = ''; private const DB = 'crackthecode'; private $link; private $table; # PUBLIC ###################################################### # METHODS ###################################################### # CONSTRUCTOR function __construct($target){ $this -> table = $target; $this -> link = mysqli_connect(self::HOST,self::USER,self::PASS,self::DB); if(!$this->link){ die("An error occured while attempting to connect to the table \"{$this -> table}\" on the ".self::DB." database.<br />Error#: ".mysqli_connect_errno()."<br />Description: ".mysqli_connect_error()); } } # PRIVATE private function checkValue($val){ switch(strtoupper($val)){ case 'NULL': return 'NULL, '; break; case 'CURRENT_TIMESTAMP': return 'CURRENT_TIMESTAMP, '; break; default: return "`".$val."`, "; } } # PUBLIC public function getData($criteria){ $query = "SELECT * FROM {$this->table} WHERE "; $crit = ""; foreach($criteria as $column => $value){ if(($column === 'bind')){ $crit .= "{$value} "; }else{ $crit .= "{$column} = {$value} "; } } $result = mysqli_query($this->link, $query.$crit); if(mysqli_num_rows($result) !== 0){ return $result; }else{ return false; } } public function newData($data){ $query = "INSERT INTO `{$this->table}` "; $cols = "("; $vals = "("; foreach($data as $col => $val){ $cols .= "`".$col."`, "; $vals .= $this->checkValue($val); } $query = $query.substr($cols,0,-2).") VALUES ".substr($vals,0,-2).")"; echo $query; echo "<br />INSERT INTO `players` (`PlayerID`, `CreatedDate`, `Username`, `Passcode`, `Email`, `FName`, `Lname`, `Addr1`, `Addr2`, `City`, `State`, `Country`, `PostalCode`, `Phone`, `PhoneType`, `TaxpayerID`, `DOB`, `TokenBalance`) VALUES (NULL, CURRENT_TIMESTAMP, 'test', 'ggb', 'hyh', 'yjj', 'hjj', 'ghu', 'ghj', 'tuo', 'dgi', 'fgu', 'iyh', 'ghk', 'Other', 'tujk', '2019-6-17', '0')"; $insert = mysqli_query($this->link, $query); //$insert = mysqli_query($this->link, "INSERT INTO `players` (`PlayerID`, `CreatedDate`, `Username`, `Passcode`, `Email`, `FName`, `Lname`, `Addr1`, `Addr2`, `City`, `State`, `Country`, `PostalCode`, `Phone`, `PhoneType`, `TaxpayerID`, `DOB`, `TokenBalance`) VALUES (NULL, CURRENT_TIMESTAMP, 'test', 'ggb', 'hyh', 'yjj', 'hjj', 'ghu', 'ghj', 'tuo', 'dgi', 'fgu', 'iyh', 'ghk', 'Other', 'tujk', '2019-6-17', '0')"); if(!$insert){ echo "An error occured while attempting to INSERT into the table \"{$this -> table}\" on the ".self::DB." database.<br />Error#: ".mysqli_connect_errno()."<br />Description: ".mysqli_connect_error(); } return $insert; } ###################################################### # End Class ###################################################### } ?> The testing page has this: <?php include '../includes/dbconn.class'; $test = new DBConnect("players"); $inserted = $test->newData([ 'playerID'=> 'NULL', 'CreatedDate'=> 'CURRENT_TIMESTAMP', 'Username'=>'test', 'Passcode'=>'123456789', 'Email'=>'test@test.test', 'FName'=>'test', 'Lname'=>'tested', 'Addr1'=>'1234 msin st', 'Addr2'=>'NULL', 'City'=>'Anytown', 'State'=>'Denial', 'Country'=>'United States', 'PostalCode'=>'12345-6789', 'Phone'=>'19995551212', 'PhoneType'=>'Other', 'TaxpayerID'=>'123-45-6789', 'DOB'=>'2019-6-17', 'TokenBalance'=>'1000000000' ]); if($inserted){echo 'Insert succeeded.';}else{echo 'Insert failed.';} ?> In the class file you will see two queries, one code generated the other from a successful phpmyadmin query. The phpmyadmin one works everytime, but the generated doent. and I cant see any difference between them when echoed except the values being inserted. please what am I doing wrong? Output from echoed queries: Generated Query: INSERT INTO `players` (`playerID`, `CreatedDate`, `Username`, `Passcode`, `Email`, `FName`, `Lname`, `Addr1`, `Addr2`, `City`, `State`, `Country`, `PostalCode`, `Phone`, `PhoneType`, `TaxpayerID`, `DOB`, `TokenBalance`) VALUES (NULL, CURRENT_TIMESTAMP, `test`, `123456789`, `test@test.test`, `test`, `tested`, `1234 msin st`, NULL, `Anytown`, `Denial`, `United States`, `12345-6789`, `19995551212`, `Other`, `123-45-6789`, `2019-6-17`, `1000000000`) PHPMyAdmin Query: INSERT INTO `players` (`PlayerID`, `CreatedDate`, `Username`, `Passcode`, `Email`, `FName`, `Lname`, `Addr1`, `Addr2`, `City`, `State`, `Country`, `PostalCode`, `Phone`, `PhoneType`, `TaxpayerID`, `DOB`, `TokenBalance`) VALUES (NULL, CURRENT_TIMESTAMP, 'test', 'ggb', 'hyh', 'yjj', 'hjj', 'ghu', 'ghj', 'tuo', 'dgi', 'fgu', 'iyh', 'ghk', 'Other', 'tujk', '2019-6-17', '0') notes mysql version: 10.0.33-MariaDB (? is that correct?)
  19. I have the following function: public function getData($criteria){ $query = "SELECT * FROM {$this->table} WHERE "; $crit = ""; foreach($criteria as $column => $value){ if($column = 'bind'){ $crit .= "{$value} "; }else{ $crit .= "{$column} = {$value} "; } } echo $crit; } I'm testing it with getData(['test1'=>'test2', 'bind'=>'AND', 'test3'=>'test4']); But instead of getting "test1 = test2 AND test3 = test4" the echo output is "test2 AND test4". I'm probably too close to see whats wrong, what do you see?
  20. I'm on a new path here and would appreciate any ideas you pros might have. I think this involves triggers and another table but am not sure. I have a project record that has fields that contain information. It's important to know when some fields change. For example, I have a field call DRAWING which contains a link to a project print. Values in this link change whenever the print is modified. It's important to know the date of the last change. When the project page is opened for review, I want to show, to the right of this field (and a few others), the date/time is was last changed. I want the time information field based, not record based. My initial idea is to trigger after a record update and compare an 'identical' table against the project table. After checking the fields of interest for change I would write the project table associated lastupdate fields with a date and then overwrite this 'identical' table with the new state of things. This all could be done with code but it gets a bit onerous. I was hoping to do it once in a stored procedure. Comments? Thank you. 10.1.38-MariaDB
  21. I was wondering if there is a way to automatically get a user's timezone? I want to show certain information if the user's current date is less than the expiry date. It works fine if the user is in a default timezone but what if the user is in a different timezone? How I can I make sure I can get their correct current time? date_default_timezone_set('America/New_York'); $expiry_date = trim($row['expiry_date']); $current_date = date('Y-m-d H:i:s'); if($current_date < $expiry_date) { // show data } else { // don't show }
  22. I have this player registration table select player_id,Fname,Lname,Gender,Shirt_no FROM player_details; +-----------+---------------------------+-----------------------------+--------+----------+ | player_id | Fname | Lname | Gender | Shirt_no | +-----------+---------------------------+-----------------------------+--------+----------+ | 1 | Manager | First-team coach | NULL | NULL | | 2 | Goalkeeping coach | Fitness coach | NULL | NULL | | 3 | Club doctor | First-team physiotherapist | NULL | NULL | | 4 | Masseur | Assistant kit manager | NULL | NULL | | 5 | Performance nutritionist | Assistant manager | NULL | NULL | | 6 | Head of performance | Head of medical services | NULL | NULL | | 7 | Assistant fitness coach | Under-21s assistant coach | NULL | NULL | | 8 | Kit manager | Equipment manager | NULL | NULL | | 9 | Football analyst | Academy manager | NULL | NULL | | 10 | Mulan | Babu | M | 23 | +-----------+---------------------------+-----------------------------+--------+----------+ 10 rows in set (0.00 sec) and this summary table select player_id,Team_catId,SeasonID from Soka_players_team_tbl; +-----------+------------+----------+ | player_id | Team_catId | SeasonID | +-----------+------------+----------+ | 1 | 1 | 12 | | 2 | 1 | 12 | | 3 | 1 | 12 | | 4 | 1 | 12 | | 5 | 2 | 12 | | 6 | 2 | 12 | | 7 | 3 | 12 | | 8 | 3 | 12 | | 9 | 3 | 12 | | 10 | 4 | 12 | +-----------+------------+----------+ if the seasonid changes,I have to reenter all the playeridsfor a particular teamcategory for every new season. for instace i will have to repeat ids 1-10 for a new seasonid 13. Iam afraid this will make the table grow very huge for all the different team categories,considering the seasons have to change,and i have to tell the players i had in a previous season how can i redesign this to avoid this in the future??
  23. select player_id,Gender,Shirt_no FROM player_details; +-----------+--------+----------+ | player_id | Gender | Shirt_no | +-----------+--------+----------+ | 10 | M | 34 | | 11 | M | 12 | | 12 | M | 13 | | 13 | M | 34 | +-----------+--------+----------+ 13 rows in set (0.00 sec) select player_id,Team_catId from players_team; +-----------+------------+ | player_id | Team_catId | +-----------+------------+ | 10 | 1 | | 12 | 2 | | 11 | 3 | | 13 | 1 | +-----------+------------+ i would like to put a check constraint on the shirt_no field,such that no player in same team category has same shirt number i have tried this: CREATE TABLE player_details ( player_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, Fname VARCHAR(60) NOT NULL, Gender ENUM('M','F'), Shirt_no tinyint(2), PRIMARY KEY (player_id ), CONSTRAINT Shirt_number_taken CHECK (NOT EXISTS -- reference to second table (SELECT * FROM Soka_players_team_tbl AS M1 WHERE M1.player_id = Soka_player_details_tbl.player_id )) ); but it is not working.
  24. i have this table structure and an array of new records, how can i run an update on all player ids with new ones for a particular matchid select player_id, MatchID,minutes from soka_player_statistics_tbl; +-----------+---------+---------+ | player_id | MatchID | minutes | +-----------+---------+---------+ | 1 | 29 | NULL | | 2 | 29 | NULL | | 3 | 29 | NULL | | 4 | 29 | NULL | | 5 | 29 | NULL | | 6 | 29 | NULL | | 7 | 29 | NULL | | 8 | 29 | NULL | | 9 | 29 | NULL | +-----------+---------+---------+ I have tried this : update soka_player_statistics_tbl set player_id=inPlayerId where MatchID=inMatchId; but if i run in an array from php to update matchID 29 with new player ids,i get an ERRNO: 256 TEXT: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-29' for key 'PRIMARY'
  25. Hello Experts, I need help on a wordpress plugin "Easy Student Results". I installed this plugin for my ITI Institute results and when entered all institution trades, courses, students separated with trades and then started adding results on the basis of trades then this plugin doesn't show results of all trades students. It only shows results of firstly created trades students results. All other trades students results are showing unavailability error. So i need your help. https://wordpress.org/plugins/easy-student-results Thank you Manish Bajpai
×
×
  • 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.