/    Sign up×
Community /Pin to ProfileBookmark

How do I update more than 1 column at a time?

I am pulling the info from form inputs. For some reason I can’t get more than 1 entry to to be updated, can someone guide me in the right direction for my “query”?

Thanks.

[code=php]
<?php

//connection information
$ser=”server”; $db=”database”; $user=”username”; $pass=”password”;

//sql connection
$conn = odbc_connect($db, $user, $pass);

$query= “UPDATE database SET Column1 = ‘$Column1’ WHERE Company_Name=’$Company_Name'”;

odbc_do($conn, $query);
?>

<html>

<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=windows-1252″>
<title>Form</title>
</head>
<body>

</body>
</html>
<?php
odbc_close($conn);
?>
[/code]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@solavarMay 09.2004 — Separate the entries by a comma,

[code=php]

$query= "UPDATE database SET Column1 = '$Column1', Column2 = '$Column2', Column3 = '$Column3' WHERE Company_Name='$Company_Name'";

[/code]
Copy linkTweet thisAlerts:
@d_brandusaauthorMay 09.2004 — Thanks so much solavar, that did it, your a lifesaver!
Copy linkTweet thisAlerts:
@pyroMay 09.2004 — You might even want to structure your query better, by using backticks around the field/table names. It can help save you some grief if you start using more complex SQL statments...

[code=php]$query = "UPDATE database SET Column1 = '$Column1', Column2 = '$Column2', Column3 = '$Column3' WHERE Company_Name = '$Company_Name';";[/code]
×

Success!

Help @d_brandusa spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...