Guest kilbad Posted August 4, 2006 Share Posted August 4, 2006 I have been trying to learn how to use mysql, somewhat successfully, using an online tutorial. However, I cannot figure out how to code a php script that will allow me to update specific rows (based on the ID number) in my mysql db. Can someone help me out by posting some code to get me started? I can then probably take it from there, and/or reply if I have further questions.The tutorial I was using (and step I got stuck on) is located at: http://www.freewebmasterhelp.com/tutorials/phpmysql/7Thank you so much in advance.Brendan Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 4, 2006 Share Posted August 4, 2006 had 2min to spere good luck[code]<?php$db=mysql_connect("localhost","xxx","xxx");mysql_select_db("database_name",$db);$query_update="update xxxxxxxx set hits='xxxx' where xxxx='xxxxxx' ";$result_query=mysql_query($query_update);?>[/code]Hope this helps everyone ok.[code]<?phpSelect StatementSELECT "column_name" FROM "table_name"DistinctSELECT DISTINCT "column_name"FROM "table_name"WhereSELECT "column_name"FROM "table_name"WHERE "condition"And/OrSELECT "column_name"FROM "table_name"WHERE "simple condition"{[AND|OR] "simple condition"}+InSELECT "column_name"FROM "table_name"WHERE "column_name" IN ('value1', 'value2', ...)BetweenSELECT "column_name"FROM "table_name"WHERE "column_name" BETWEEN 'value1' AND 'value2'LikeSELECT "column_name"FROM "table_name"WHERE "column_name" LIKE {PATTERN}Order BySELECT "column_name"FROM "table_name"[WHERE "condition"]ORDER BY "column_name" [ASC, DESC]CountSELECT COUNT("column_name")FROM "table_name"Group BySELECT "column_name1", SUM("column_name2")FROM "table_name"GROUP BY "column_name1"HavingSELECT "column_name1", SUM("column_name2")FROM "table_name"GROUP BY "column_name1"HAVING (arithematic function condition)Create Table StatementCREATE TABLE "table_name"("column 1" "data_type_for_column_1","column 2" "data_type_for_column_2",... )Drop Table StatementDROP TABLE "table_name"Truncate Table StatementTRUNCATE TABLE "table_name"Insert Into StatementINSERT INTO "table_name" ("column1", "column2", ...)VALUES ("value1", "value2", ...)Update StatementUPDATE "table_name"SET "column_1" = [new value]WHERE {condition}Delete From StatementDELETE FROM "table_name"WHERE {condition}?>[/code] Quote Link to comment Share on other sites More sharing options...
ronverdonk Posted August 4, 2006 Share Posted August 4, 2006 Okay, to give you a specific exemple of an update:UPDATE my_table SET column_a = 'abc' WHERE id = 0Change column_a to value 'abc' for every row in table my_table where column id contains the value 0.assuming that column_a is a character type column and column id is a numeric type column. Quote Link to comment Share on other sites More sharing options...
Guest kilbad Posted August 4, 2006 Share Posted August 4, 2006 thank you, that's just what I needed!Brendan Quote Link to comment Share on other sites More sharing options...
ronverdonk Posted August 4, 2006 Share Posted August 4, 2006 What was it you needed, the overview or the specific example? Quote Link to comment Share on other sites More sharing options...
Guest kilbad Posted August 4, 2006 Share Posted August 4, 2006 The specific example was the most helpful. Thanks again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.