Jump to content

updating query


sofia403

Recommended Posts

hi , just wondering if this query is missing something or entered incorrect. I'm trying to update a value in db with a Submit from php. thank you.

 

$city = $_POST['city'];

if(isset($_POST['Submit'])){

$query=( "INSERT INTO country CITY VALUES '$city'");}

Link to comment
Share on other sites

um, well im guessing it will have to be both ? i already have some entry in db, when users log in i just want them to either update existing records or just add a new value in some of the fields. Also i have separate "Update" button for each column.

 

So if "User1" logs in he already has a n entry in "city" so i want him be able to change that value, while "User2" might not have the city in the db yet.

 

Link to comment
Share on other sites

 

MySQL version 5.0.81-community-log

 

Hello, im still trying to find an answer how i can go about creating a query that would update or insert a value based on if an entry already exists or not in a table I'm using the query below, but its not working (not updating nor inserting anything) and i don't get any errors.

 

i copied this query from the web some place and not quite sure if this is best way to go about it.

 

So i have ApplicationStatus column where users input (In Process, Withdrawn and so on)and i want the user when he logs into their profile be able to update that field, they might have a value there or they might have it empty, so its either has to be insert or update i guess? can someone please take a look at it, and point me in the right direction. thank you. also i dont know if mysql version is enough or you might need something else here?  I could provide more information if needed. thanks

 

UPDATE country SET ApplicationStatus='1' WHERE ApplicationStatus=echo ('$ApplicationStatus').
IF @@ROWCOUNT=0 INSERT INTO country VALUES '$_POST[ApplicationStatus]'

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.