Creating PHP printf string with database variables

I need to build into my currently functioning printf() string a variable pulled from my mySql table.

Here's the existing code:
<?php
$atsign="@";
$today = Date("Y-m-d");
$startdt = date('Y-m-d', strtotime('-5 days'));

$db = mysql_connect("localhost", "root");
mysql_select_db("fullinfo",$db);
$sql = "SELECT SUBSTRING_INDEX(wemail,'@',1) as 'leftemail',SUBSTRING_INDEX(wemail,'@',-1) as 'rightemail',SUBSTRING_INDEX(wemail,'.',-1) as 'dotcom',date_format(wdate,'%b %e') as 'thedate', DATE_FORMAT(wdate,'%Y-%M-%e') as passdate,wstate FROM w100 where wdate>='$startdt' and wdate<'$today' order by wdate desc";
$result = mysql_query($sql,$db) or die("Couldn`t execute query");

if ($myrow = mysql_fetch_array($result)) {

  do {

    printf("<tr><td height=24><font style='font-family:arial,helvetica,sans-serif;color: #335399;font-size: 12px;'>%s</font></td><td><a href='/cgi-bin/tixcheck.cgi?t=XXX target='_blank'><font style='font-family:arial,helvetica,sans-serif;color: #335399;font-size: 12px;'>%s</font></a></td></tr>\n", $myrow["thedate"], substr($myrow["leftemail"],0,1)."____$atsign".substr($myrow["rightemail"],0,1)."_____.".$myrow["dotcom"]);

  } while ($myrow = mysql_fetch_array($result));

}

?>

The above works correctly.  Now I need to replace the XXX in the a href string with $myrow["passdate"] variable pulled from my table.

How can this be done?
kkbenjAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

frugleCommented:
   printf("<tr><td height=24><font style='font-family:arial,helvetica,sans-serif;color: #335399;font-size: 12px;'>%s</font></td><td><a href='/cgi-bin/tixcheck.cgi?t=%s target='_blank'><font style='font-family:arial,helvetica,sans-serif;color: #335399;font-size: 12px;'>%s</font></a></td></tr>\n", $myrow["thedate"], $myrow["passdate"], substr($myrow["leftemail"],0,1)."____$atsign".substr($myrow["rightemail"],0,1)."_____.".$myrow["dotcom"]);


unless I'm mistaken.

Mike
0
BenMorelCommented:
It seems correct to me.
Ben
0
kkbenjAuthor Commented:
I used this:
 printf("<tr><td height=24><font style='font-family:arial,helvetica,sans-serif;color: #335399;font-size: 12px;'>%s</font></td><td><a href='/cgi-bin/tixcheck.cgi?t=%s target='_blank'><font style='font-family:arial,helvetica,sans-serif;color: #335399;font-size: 12px;'>%s</font></a></td></tr>\n", $myrow["thedate"], $myrow["passdate"], substr($myrow["leftemail"],0,1)."____$atsign".substr($myrow["rightemail"],0,1)."_____.".$myrow["dotcom"]);

and it gave an error:
Parse error: parse error, unexpected T_STRING in ctop10.php on line 139 (this is the printf line)

 So I added the ' to make it:
    printf("<tr><td height=24><font style='font-family:arial,helvetica,sans-serif;color: #335399;font-size: 12px;'>%s</font></td><td><a href='/cgi-bin/tixcheck.cgi?t='%s target='_blank'><font style='font-family:arial,helvetica,sans-serif;color: #335399;font-size: 12px;'>%s</font></a></td></tr>\n", $myrow["thedate"], $myrow["passdate"], substr($myrow["leftemail"],0,1)."____$atsign".substr($myrow["rightemail"],0,1)."_____.".$myrow["dotcom"]);

This got rid of the error, but the date is not part of the link URL.

What am I missing?
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

BenMorelCommented:
This is correct :

printf("<tr><td height=24><font style='font-family:arial,helvetica,sans-serif;color: #335399;font-size: 12px;'>%s</font></td><td><a href='/cgi-bin/tixcheck.cgi?t=%s' target='_blank'><font style='font-family:arial,helvetica,sans-serif;color: #335399;font-size: 12px;'>%s</font></a></td></tr>\n", $myrow["thedate"], $myrow["passdate"], substr($myrow["leftemail"],0,1)."____$atsign".substr($myrow["rightemail"],0,1)."_____.".$myrow["dotcom"]);

It was : =%s'
And not :f ='%s

Regards,
Ben
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kkbenjAuthor Commented:
I split the points because the first solution was missing the single quotation that I needed.

Thanks to both of you!
0
kkbenjAuthor Commented:
How can I add
onmouseover="window.status=' ';return true;"
to this string?
0
BenMorelCommented:
I think this is what you want :

printf("<tr><td height=24><font style='font-family:arial,helvetica,sans-serif;color: #335399;font-size: 12px;'>%s</font></td><td><a href='/cgi-bin/tixcheck.cgi?t=%s' target='_blank' onmouseover=\"window.status=' ';return true;\"><font style='font-family:arial,helvetica,sans-serif;color: #335399;font-size: 12px;'>%s</font></a></td></tr>\n", $myrow["thedate"], $myrow["passdate"], substr($myrow["leftemail"],0,1)."____$atsign".substr($myrow["rightemail"],0,1)."_____.".$myrow["dotcom"]);

(You need to replace " with \")
0
kkbenjAuthor Commented:
Perfect!

You are fantastic!!!!!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.