I first posted this as a branch of a now defunct thread. Thank you, Sridhar
Balasubramanian.
I'm really new to both PHP and mySQL, and not very experienced in writing much
of any code beyond HTML, so much of what I need to know is probably trivial to
most of this list, but I'm in love with PHP, and I catch on pretty quick. So be
patient with me.
I've now managed to setup an operating PHP interface to a working mySQL
database that contains contact and donor information for a non profit
foundation. The PHP I'm using is a heavily rebuilt all purpose script I found
on the web, and it works well. I can search, browse, edit, delete, add and
display records in a useful format. Now I want to display the record count at
the top of the results, and to do that, I have to put the output from a
while loop into a variable in order to control the placement. I understand
that.
In other places in the script, I've used a technique I found somewhere (I don't
remember what it's called, but it looks like this:
$banner=<<<endbanner
<table><tr><td><img src="http://www.whatever.org/assets/graphics/logo.gif"
width="450" height="113" alt="The Whatever
Foundation"></td></tr><tr><td><B>Search Results</B></td></tr></table>
endbanner;
echo $banner;
This works fine, but when I try the same method with the output of the while
loop, I get various parse errors that I can't fix.
Here is the entire while loop, the results of which I'm trying to put into a
variable so that by printing the variable I can control placement on the page.
Can anyone help?
while ($myrow = mysql_fetch_array($result)) {
printf("<p><a href=\"editList.php?personID=%s\"> %s %s</a> <-- Click on name
to edit record.
<br>----------------------------------------------------------------------------
-------------------<br>
eMail........: %s <br>
Address1.....: %s <br>
Address2.....: %s <br>
City.........: %s <br>
State........: %s <br>
PostalCode...: %s <br>
Country......: %s
<br>----------------------------------------------------------------------------
-------------------<br>
Phone.......: %s<br>
Fax.........: %s<br>
CellPhone...: %s
<br>----------------------------------------------------------------------------
-------------------<br>
rgNewsType........: %s<br>
rg_DonorType......: %s<br>
rgVolunteerType...: %s <br>-----------------------------------------------------
------------------------------------------<br>
ccNum...........: %s<br>
ccExp...........: %s<br>
ccCVV...........: %s <br>-------------------------------------------------------
----------------------------------------<br>
Notes..: %s </p>\n",
$myrow["personID"],
$myrow["FirstName"],
$myrow["LastName"],
$myrow["eMail"],
$myrow["Address1"],
$myrow["Address2"],
$myrow["City"],
$myrow["State"],
$myrow["PostalCode"],
$myrow["Country"],
$myrow["Phone"],
$myrow["Fax"],
$myrow["CellPhone"],
$myrow["rgNewsType"],
$myrow["rg_DonorType"],
$myrow["rgVolunteerType"],
$myrow["ccNum"],
$myrow["ccExp"],
$myrow["ccCVV"],
$myrow["Notes"]);
$recordCount++;
}
Everything I've tried results in parse errors of one sort or another.
Thank you.