SitePoint Enthusiast
i've managed to code so that the records in my "proj" table are diplayed the way i want, but i would like the page to display something simple like "End of Files" when all are printed. i'm assuming a "while - else" loop would be applicable here, but none of my attempts work.
Here is the code as i have it presently:
<?php
$result = mysql_query("SELECT * FROM proj",$dbcnx);
printf("<font size='-1' face='Arial, Helvetica, sans-serif'><P><b>Project: %s<br></b></font>\n", mysql_result($result,0,"name"));
printf("<font size='-1' face='Arial, Helvetica, sans-serif'>Project Complete: %s<br></font>\n", mysql_result($result,0,"projcomplete"));
printf("<font size='-1' face='Arial, Helvetica, sans-serif'>Pages Complete: %s<br></font>\n", mysql_result($result,0,"pagecomplete"));
printf("<font size='-1' face='Arial, Helvetica, sans-serif'>Database: %s<br></font>\n", mysql_result($result,0,"db"));
printf("<font size='-1' face='Arial, Helvetica, sans-serif'>Updated: %s<br></font></p>\n", mysql_result($result,0,"updated"));
?>
anyone have the input to tweat it to do what i want?
thanks all.
SitePoint Enthusiast
P.S. if anyone knows if there is a "cleaner way to do the above code, please lete me know. i have the feeling it could be smaller and more efficient.
Cleaner? I'd take this part: "<font size='-1' face='Arial, Helvetica, sans-serif'>" and I'd stick in a variable
$textformatting = "("<font size='-1' face='Arial, Helvetica, sans-serif'>"
Might work...
------------------
Chris Bowyer - Programmer in Training
MyCoding.com: Join our mailing list for launch notification!
"I'm not an insomniac, I'm a web designer."
tinyitn,
I suggest you read Part 4 of my series, "Building aDatabase-Driven Website using PHP and MySQL": Publishing MySQL Data on the Web . Specifically, the section entitled Handling SELECT Result Sets has the answers you need.
Displaying result sets using while loops is covered in detail, with several examples for you to work from. If you still need help after reading that, let me know and I'll post some code.
------------------
-Kevin Yank.
http://www.SitePoint.com/
Helping Small Business Grow Online!
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks