/    Sign up×
Community /Pin to ProfileBookmark

Send MYSQL rows via email

hi everyone, i see this script in your site

[code=php]<?php
include(‘connect-db.php’);
$query = “SELECT data FROM players WHERE id='”.$_GET[‘id’].”‘”;
$to = “[email protected]”;
$subject = “Your feedback, sir.”;

$result = mysql_query($query);
if($result)
{
if(mysql_num_rows($result))
{
$message = mysql_result($result, 0);
if(mail($to, $subject, $message, $headers))
{
echo “IT WORKED!!!!”;
}
else
{
echo “Sorry, there was a problem sending the email.”;
}
}
else
{
echo “Sorry, no matching data was found, email not sent.<br>”;
die(“No row returned: $query”);
}
}
else
{
echo “Sorry, there was a problem with the database–email not sent.<br>”;
die(mysql_error().”n”.$query);
}
?>[/code]

but i wnat to invie multi rows and not only data but also data2,data3,data4…. how i modified this for send multi rows?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmOct 24.2015 — All this is doing is pulling a data field from the one row that was selected and emailing it.

If you want to do a query that yields more than one data field per row, all you have to do is pull them out (use a fetch command instead of the one you used here) and add those variables to your email. If you want to do a query that yields multiple rows with multiple fields, then the problem is just a bit more complex but very much like what I just described.

Note: you should not use this script as written since the MySQL-* functions are deprecated and should not be used. Switch to PDO. Read about it in the manual
×

Success!

Help @roleplaytwo 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.6,
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,
)...