cartaysm
-
Posts
6 -
Joined
-
Last visited
Posts posted by cartaysm
-
-
Thank you for your response. That isnt exactly what I was looking for, the place you added a counter is working fine, that pulls a single column and counts it. The problem I am having is that if I use that select statement i will have to use about 100 different statements which seems like a waste.
The other option is below where I iterate through an array that was built with joins, the problem is that it only pulls 1 record. I could try and add a counter to the iteration to see if produces more values. Is that what you meant?
$registeredinfo = array_count_values($stmt->fetch_assoc());
foreach ($registeredinfo as $key => $val) {
print "$key = $val <br />";
}
-
I want to count column values in a few different tables with different filters...
I can do the long way which would be like this;
$result = $mysqli->query("SELECT COUNT(Gender) FROM table where Gender = 'F'");
$Female = $result->fetch_row();
$result = $mysqli->query("SELECT COUNT(Class) FROM table2 where Class = 'SprintT'");
$ST = $result->fetch_row();
$result = $mysqli->query("SELECT COUNT(Class) FROM table2 where Class = 'SprintD'");
$SD = $result->fetch_row();
Which allows to me edit the page anyway I want, but seems like a waste to connect to the database 100 times just for the data when I could do something like below.
Or I can search the follow way;
$builder = "SELECT ";
$builder .= "b.Gender, b.State, b.Country, ";
$builder .= "d.Class, d.Category, d.ShirtSize, d.Hear, d.AmountPaid, d.Discounts, d.Status ";
$builder .= "FROM table = b ";
$builder .= "LEFT OUTER JOIN table2 = d ";
$builder .= "on b.id = d.ID";
$stmt = $mysqli->query($builder);
$registeredinfo = array_count_values($stmt->fetch_assoc());
foreach ($registeredinfo as $key => $val) {
print "$key = $val <br />";
}
Produces;
M = 1
Ohio = 1
USA = 1
SprintT= 1
AgeGroup = 1
PreviouslyParticipated = 1
But this doesn’t seem to go through all lines I pull, example if I had 2 lines instead of one I would expect the numbers to change to 2 but they remain at 1.
Anyone have any ideas how I pull a lot of categories and then count them efficiently?
-
I have swift mailer setup to send two message and plain and HTML. I have followed a lot of different posts and came up with a solution that works. However when I send for example 7k emails only about 500 made it out before the 30sec timeout. So I switched my timeout to 600secs and only about 3k made it out.
I now I can switch my timeout to 0 or 3600sec and it will go through but it doesnt seem like this should take so long.
I use Debian 6.0, Zimbra 7, Postfix, and SwiftMailer
I am using the mailer like this;
/ Create the Transport
$transport = Swift_SmtpTransport::newInstance('localhost', xx)
->setUsername('xxx')
->setPassword('xxx')
;
// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
//Starts the loop to separate the to email addresses everything past here is built for each email
$to1 = explode(", ", $to);
for($i = 0; $i < count($to1); $i++){
// Create a message
$message = Swift_Message::newInstance($subject)
->setFrom(array($from => 'xxx'))
->setTo(array($to1[$i]))
->setBody($plaintxt)
->addPart($htmltxt, 'text/html');
$plaintxt = substr($plaintxt, 0, -$plaindumplength);
$htmltxt = substr($htmltxt, 0, -$dumplength);
$emailcounter += $mailer->send($message);
}
-
I could be wrong but shouldn't this;
$connect = mysql_connect ("localhost","","") or die ("couldn't connect!");
mysql_select_db ("phplogin") or die ("couldn't find db!");
read more like this;
$connect = mysql_connect ("localhost","","") or die ("couldn't connect!");
mysql_select_db ("phplogin", $connect) or die ("couldn't find db!");
-
I sent an MIME email to an outlook account using Mail() and the HTML part was placed as an attachment for some reason. I dont get caught by most spam filters (just outlook and my school) but I wanted to get this worked out so I dont get caught by any spam filters. Can someone please take a look at my email system below and let me know if everything looks correct?
Just in case you need this; I am using PostFix, Zimbra, running on Debian 6.0 (php5)
//add From: header
$headers = 'From:' . $from . "\n";
$headers .= 'Reply-To:' . $from . "\n";
$headers .= 'Return-Path:' . $from . "\n";
//specify MIME version 1.0
$headers .= "MIME-Version: 1.0\n";
//unique boundary
$boundary = uniqid("market");
//tell e-mail client this e-mail contains//alternate versions
$headers .= "Content-Type: multipart/mixed; boundary = $boundary\r\n\r\n";
//plain text version of message
$body = "--$boundary\r\n" .
"Content-Type: text/plain; charset=ISO-8859-1\r\n" .
"Content-Transfer-Encoding: base64\r\n\r\n";
//adds the remove to the string
$body .= chunk_split(base64_encode($plaintxt));
//HTML version of message
$body .= "--$boundary\r\n" .
"Content-Type: text/html; charset=ISO-8859-1\r\n" .
"Content-Transfer-Encoding: base64\r\n\r\n";
$body .= chunk_split(base64_encode($htmltxt));
$message = stripcslashes($body);
$subject = stripcslashes($subject);
mail($to1[$i], $subject, $message, $headers, "-f $from");
mysqli count
in MySQL Help
Posted
As it turns out I finally found the answer just posting it for anyone else that stumble accross this
This code will pull multiple rows and then split and count each row...