/    Sign up×
Community /Pin to ProfileBookmark

arg checkboxes

ok.. im having problems what i need to happen is if the check box is checked it needs to send the values from the form to two different tables and when its uncheckd to send to one table my coding is..

[code=php]<?php
$conn = mysql_connect(“localhost”, “*****”, “********”);
mysql_select_db(“ebay”,$conn);
$sqlebay = “insert into nametable values(‘$_POST[name1]’, ‘$_POST[name2],’, ‘$_POST[name3]’, ‘$_POST[select]’)”;
mysql_select_db = (“apccompunet, $conn);
$sqlapc = “insert into nametable values (‘$_POST[name1]’, ‘$_POST[name2]’, ‘$_POST[name3]’, ‘$_POST[select]”);
if $_POST[apcreg] = apcreg {
mysql_query($sqlebay, $sqlapc, $conn) or die(mysql_error());
echo “added to apc and ebay”;
} else {
mysql_query($sqlebay, $conn) or die(mysql_error());
echo “added to ebay”;
};
?>[/code]

oh before i forget i dont get any error messages when i view the page

thanks ?

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogAug 13.2004 — My best guess at what you mean/want plus fixing some - make that a lot of - punctuation problems:
[code=php]
<?php
$conn = mysql_connect("localhost", "k0m0d0", "ragnarok");
$sql = sprintf("insert into nametable values('%s', '%s', '%s', '%s');", $_POST['name1'], $_POST['name2'], $_POST['name3'], $_POST['select']);
if($_POST['apcreg'] == "apcreg")
{
mysql_select_db("ebay",$conn);
mysql_query($sql,$conn) or die(mysql_error());
mysql_select_db("apccompunet", $conn);
mysql_query($sql,$conn) or die(mysql_error());
echo "added to apc and ebay";
}
else
{
mysql_select_db("ebay",$conn);
mysql_query($sqlebay, $conn) or die(mysql_error());
echo "added to ebay";
}
?>
[/code]
Copy linkTweet thisAlerts:
@s33nauthorAug 13.2004 — hey, thanks but it still dont work.

First what does the sprintf mean and the ('%s') mean?

what i want is that it will always put the info into the ebay database but if the check box is click (apcreg) it will ALSO put the same data into the apccompunet database. (they r different db and not just tables)

I hope this is clearer thanks
Copy linkTweet thisAlerts:
@NogDogAug 13.2004 — [i]Originally posted by s33n [/i]

[B]hey, thanks but it still dont work.



First what does the sprintf mean and the ('%s') mean?



what i want is that it will always put the info into the ebay database but if the check box is click (apcreg) it will ALSO put the same data into the apccompunet database. (they r different db and not just tables)



I hope this is clearer thanks [/B]
[/QUOTE]

[url=http://us3.php.net/manual/en/function.sprintf.php]sprintf() explained[/url] (www.php.net is your friend. ? )

The checkbox variable will only be received if it is checked, and since the one query is always done, we could streamline the code a bit using this logic:
[code=php]
if(isset($apcreg))
{
# do the APC query stuff here
}
# do the EBAY query stuff here
[/code]
Copy linkTweet thisAlerts:
@s33nauthorAug 13.2004 — hehe cheeres mate its fixed now ?
×

Success!

Help @s33n 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 6.1,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...