473,395 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

insert the email id its not exit; if exit only update the row do not insert again

i have table in which first time insert the value in table
and second time when i was login with same email update row did no insert again.
my problem is that when i was my query my table is updated but insert once again the in next row;
i want that only update did not insert again
please solve my problem as soon as possible for you
here i am sending my php code below
Expand|Select|Wrap|Line Numbers
  1. if(!isset($_SESSION['user']))
  2. {
  3.     header("Location: ../index.php");
  4. }
  5.  
  6. $email=$_SESSION['user'];
  7. $res=mysql_query("SELECT * FROM user_businessleads WHERE user_email='$email'");
  8. $row=mysql_fetch_array($res);
  9.  
  10.   if(isset($_POST['submit']))
  11.   {
  12.        $looking_for = $_POST['looking_for'];
  13.         $services = $_POST['services'];
  14.         $mybudget = $_POST['mybudget'];
  15.         $around = $_POST['around'];
  16.         $s_reguirement = $_POST['s_reguirement'];
  17.         $chk="";
  18.     $email=$_SESSION['user'];  
  19.      foreach($services as $chk1)  
  20.    {  
  21.       $chk .= $chk1.",";
  22.  
  23. }
  24.  
  25.        $query=mysql_query("INSERT INTO user_businessleads(services,user_email,looking_for,mybudget,around,s_requirment)values('$chk','$email','$looking_for','$mybudget','$around','$s_reguirement')"); 
  26. }
  27.  if(isset($_POST['submit']))
  28.   {
  29.        $looking_for = $_POST['looking_for'];
  30.         $services = $_POST['services'];
  31.         $mybudget = $_POST['mybudget'];
  32.         $around = $_POST['around'];
  33.         $s_reguirement = $_POST['s_reguirement'];
  34.         $chk="";
  35.     $email=$_SESSION['user'];  
  36.      foreach($services as $chk1)  
  37.    {  
  38.       $chk .= $chk1.",";
  39.  
  40. }
  41.  $updated=mysql_query("UPDATE user_businessleads SET services='$chk',looking_for=' $looking_for',mybudget='$mybudget',around='$around',s_requirment='$s_reguirement' WHERE user_email='$email'")or die;
  42. }
  43. ?>
Mar 7 '16 #1
0 1185

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Derek Erb | last post by:
SQL Server 2000 : I have a series of tables which all have the same structure. When any of these tables are modified I need to syncrhonise all of those modifications with one other table wich is a...
14
by: serge | last post by:
I have a scenario where two tables are in a One-to-Many relationship and I need to move the data from the Many table to the One table so that it becomes a One-to-One relationship. I need to...
1
by: luna | last post by:
trying to create an update/insert button basically if the record exists in the database i want to do an update if it doesnt exist i want to create a new record using insert all using the same...
4
by: Chris Kratz | last post by:
Hello all, We have run into what appears to be a problem with rules and subselects in postgres 7.4.1. We have boiled it down to the following test case. If anyone has any thoughts as to why...
2
by: Eduardo Pérez Ureta | last post by:
How may I do a INSERT ON DUPLICATE KEY UPDATE like in mysql: http://dev.mysql.com/doc/mysql/en/INSERT.html ? Eduardo ---------------------------(end of broadcast)---------------------------...
3
by: V T | last post by:
Hello all, SQL Server 2000 documentation http://www.microsoft.com/technet/prodtechnol/sql/2000/reskit/part10/c3761.mspx states that if view is using "NOT NULL" columns of a base table, then...
0
by: Daniel | last post by:
update/insert with microsoft.xml.xquery(.net2.0beta) can anyone provide an example of how to update/insert with microsoft.xml.xquery?
3
by: rhaazy | last post by:
Using ms sql 2000 I have 2 tables. I have a table which has information regarding a computer scan. Each record in this table has a column called MAC which is the unique ID for each Scan. The...
2
by: technocraze | last post by:
Hi guys, I have encountered this error when updating the values to the MS Acess table. Error : Update on linked table failed. ODBC sql server error Timeout expired. MS Acess is my front end and...
1
by: sridhar4554 | last post by:
How to give a grant like select,update,insert on a single table i had tried with the command grant eg:GRANT SELECT,INSERT,UPDATE ON DTS_OUTBOX_QUEUE TO sanpapps@dap1 IDENTIFIED BY 'disable';...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.