HTML
JavaScript
Windows
Linux
Java
MySql
Home
»
questions
»
Mysql(+PHP) database Insert?
Mysql(+PHP) database Insert?
2
2006-08-19 03:15:03, Category: Programming & Design
How can I insert data to my database, ONLY IF there isnt any similar data already in it. And If it exists, then updates it.
Answers
Bruno
On 2006-08-19 03:19:04
REPLACE INTO dbname etc
Michael T
On 2006-08-19 20:40:58
Try something like this: $sql_result = MYSQL($dbName, "SELECT field_id, field_name FROM $dbTable where field_name='$var' LIMIT 1"); $num_rows = mysql_num_rows($sql_result); if ($num_rows == 1) { while ($row = mysql_fetch_array($sql_result)) { $field_id = $row["field_id"]; $sql_modify = MYSQL($dbName, "UPDATE $dbTable SET field_name='$new_var' WHERE field_id='$field_id'"); } } else { $sql_insert = MYSQL($dbName, "INSERT INTO $dbTable ( field_name ) VALUES ('$new_var')"); }
Browse Questions
Keep computer active?
What size (width and height) does a 'centered' jpeg image background need to be?
whats the first easiest programming language used for beginner computer programmers?
i want to make animated cartoons and films can any one tell me which course i should do?
Does Microsoft have a keynote address like Apple?
How Do I Remove Popcorn.net?
How do you customize your scrollbar on Livejournal?
Myspace contact table prb?
HELP. I want make a specific website and have no idea how to go about doing it?
r u experience in java script and asp.Net?
Add comments , View comments on myspace?
Can you give me advice on giving advice?
A questioner was just asking about a serial number or code.?
gimp..........?
Could someone tell me how to burn music on CD, and is there a specific kind of CD or DVD Im suppose
how is info. represented when stored in a .wav file and how can i get render into numerical quantiti
recvfrom():how to receive multiple UDP packets.?
What is the beverage of choice by techno-weenies and propeller-heads?
Is Green The way to Go when it comes to powering a building that is non-profit?
Can Anybody Tell me Some Linux Commands.?
Answers
Bruno
On 2006-08-19 03:19:04
Michael T
On 2006-08-19 20:40:58