How to Update one column (point) in php sql [duplicate] - php

This question already has answers here:
Using variables in MySQL UPDATE (PHP/MySQL)
(3 answers)
Closed 7 years ago.
Please help me to write full code in php and sql to update only (point) in table below.
table name : tuser
id_user : 12
name : lisa
username : lisa1990
password : User123
point : 12930

It is very easy...
$con = mysql_connect("servername","username","password");
mysql_select_db("databasename");
$command = "UPDATE tuser SET point='your value' where id=whatever";
//replace 'your value' with the new value and "whatever" with the user id
mysql_query($command);
mysql_close_connection($con);
Next time don't ask so stupid questions here... use Google

Related

Get count of Referer domain from users Database [duplicate]

This question already has an answer here:
Group by substring
(1 answer)
Closed 4 years ago.
how can i get count of all domain from users from database
example:
id user refurl
1 ultraman https://google.com/asd/a3sd/asd.html
2 Kingogthe https://google.be/asd/as2d/asd.html
3 biomanliv https://google.ttr/asd/a1sd/asd.html
4 amanrras https://google.mmo/asd/a4sd/asd.html
5 talllos https://yahoo.cosdm/asd/a5sd/asd.html
6 bicenoza https://yahoo.gd/asd/as6d/asd.html
7 Linliveagi https://www.bing.cp/asd/as6d/asd.html.
8 fkbareshuy https://www.bing.cdd/asd/as6d/asd.html
The output to be like:
4 from google
2 from yahoo
2 from bing
etc.
I tried "SELECT COUNT(*) ......" but didn't work how i wanted to
and i tried to use parse_url['host']
$url = parse_url['host'];
$getdomainonly = explode('.',$url);
echo $getdomainonly[0];
//here you get domain without com net Example: https://google.com/asd/aasd to only google
but i don't know how to use this php code with SQL to get the output
if you want to know:
I run script on php 5.6 but i can change it if there is answer for 7.0,7.1 or 7.2
I use MySql to saved data
Because you have tagged php, I'm going to guess that you are using MySQL. If so, you can do:
select substring_index(substring_index(refurl, '.', 1), '//', -1) as domain,
count(*)
from example
group by domain;

PHP - How to update table using auto increment (value++) [duplicate]

This question already has answers here:
Increment value in MySQL update query
(10 answers)
Closed 6 years ago.
someone can tell me how to update the value from 0 to 1, 52 to 53 (value++) using php script?
i want to search it on go*gle but i dunno the keyword to find it
If you want to update one column, for example 5_sagnat_baik - just run the query:
UPDATE `question` SET `5_sagnat_baik` = `5_sagnat_baik` + 1
You may update your auto-increment column (known as 'id') using a "update" sql in your php script using something like:
'UPDATE table_name SET id=(id + 1), [column2]=[value2], ...'
OR with PHP computed values (here $current_value):
'UPDATE table_name SET id=' . $current_value + 1 ', [column2]=[value2], ...'
The SQL update request is explained here: http://www.w3schools.com/SQl/sql_update.asp (or here: https://mariadb.com/kb/en/mariadb/update/#syntax)
"UPDATE table_name
SET column_name = column_name+ 1
WHERE condition";
Hope this help

how to find who is department head of employee USING IN CLAUSE in php [duplicate]

This question already has answers here:
Passing an array to a query using a WHERE clause
(17 answers)
Closed 6 years ago.
$department_id=19
$deptshead(17,19,3)
$sql_depthead ="SELECT * FROM nonaudit_employee WHERE status = 'Active' AND rights = 3 AND deptshead IN(".$department.")AND cand_id!= ".$cand_id;
its working fine but
it only match first dept head cant check the second dept value???
I'm not sure if I correct understood.
You can try to use:
$inClause = implode(",", $deptshead);
And after that use $inClause var in your query

Check MySQL for duplicate entry [duplicate]

This question already has answers here:
How to check if a row exists in MySQL? (i.e. check if username or email exists in MySQL)
(4 answers)
Closed 6 years ago.
I am modifying a web application that was built in PHP by another developer. Currently, if the user fills out a form and enters a username that is already being used, it displays the MySQL error Duplicate entry 'fred' for key 'username' on a new page. I want to make it so that an error message is displayed on the same page, so I'm trying to check if the username entered matches another username in the table, but I cannot get it to work. Any thoughts?
$username_entry = ($_POST['username']);
$username_match = mysql_query("SELECT * FROM business WHERE username='$username_entry'");
if (($_POST['username']) == $username_match ) {
// do something
}
first of all you're not returning anything from your query to check against. I query the db to see if any rows return with that username. $cnt is the number of rows so if that is greater than zero you have a duplicate.
$username_entry = ($_POST['username']);
$username_match = mysql_query("SELECT count(*) FROM business WHERE username='$username_entry'");
$cnt = mysql_num_rows($username_match);
if (($cnt > 0 ) {
// do something
}

How to get all parameters in MSSQL Stored Procedure [duplicate]

This question already has answers here:
Find the parameter names of a stored procedure
(3 answers)
Closed 8 years ago.
When I was using asp, I was able to do the following - now I am using php and sqlsrv - how do I achieve the same in php
Set oCmd = Server.CreateObject("ADODB.Command")
Set oCmd.ActiveConnection = oConn
oCmd.CommandText = "dbo.spGetItem"
oCmd.CommandType = &H0004 'adCmdStoredProc
oCmd.Parameters.Refresh
For Each prmTemp In oCmd.Parameters
Response.Write( prmTemp.direction & "<br/>" & prmTemp.name)
Next
Set oCmd = Nothing
The simplest way regardless of client language is to just query the metadata / catalog views:
SELECT name, is_output
FROM sys.parameters
WHERE [object_id] = OBJECT_ID('dbo.spGetItem');
select ORDINAL_POSITION, PARAMETER_NAME, DATA_TYPE, PARAMETER_MODE from information_schema.parameters
where specific_name='Proc_Name'

Categories