Welcome to Dream.In.Code
Become a PHP Expert!

Join 150,177 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,162 people online right now. Registration is fast and FREE... Join Now!




Display Results In Only 1 Table W/ 1 Col 1 Row

 
Reply to this topicStart new topic

Display Results In Only 1 Table W/ 1 Col 1 Row

HowdeeDoodee
27 Aug, 2008 - 05:23 AM
Post #1

D.I.C Head
**

Joined: 17 Jun, 2008
Posts: 67

The following code prints a search result in an individual box for each record found. Instead of printing an individual box for each record found, I would like all the records to appear in the same box with the blue background. I am sure this is possible but I do not know how to do it.

Thank you in advance for your thoughts and for putting up with my recent ineptitudes in making requests. smile.gif


CODE

if (mysql_num_rows($result5) > 0) {  
while ($row = mysql_fetch_row($result5)) {
echo "<br />";
$ShowVerseText[$N + 1] = $row[0];
$X = $ShowVerseText[$N + 1];
echo "<table align=\"center\">\n";
echo "  <center>\n";
echo "  <table border=\"1\" width=\"700\" height=\"25\" cellspacing=\"0\" bgcolor=\"#D8E0F0\">\n";
echo "    <tr>\n";
echo "      <td width=\"700\"><font face=\"Arial\" size=\"2\"><i>$X</i></font></td>\n";
echo "    </tr>\n";
echo "  </table>\n";
echo "  </center>\n";
echo "</table>";
}
}
}
else {
    // print status message
    echo "No rows found!";
}


Thank you again.
User is offlineProfile CardPM
+Quote Post

Computer_
RE: Display Results In Only 1 Table W/ 1 Col 1 Row
27 Aug, 2008 - 05:53 AM
Post #2

New D.I.C Head
*

Joined: 22 Aug, 2008
Posts: 16



Thanked: 1 times
My Contributions
When reading the result you have to put for each row different <tr> , then the information inside , then </tr> closing tag.
That's why I moved the 'while' contrlo structure.

CODE

if (mysql_num_rows($result5) > 0) {  

echo "<br />";

echo "<table align=\"center\">\n";
echo "  <center>\n";
echo "  <table border=\"1\" width=\"700\" height=\"25\" cellspacing=\"0\" bgcolor=\"#D8E0F0\">\n";

while ($row = mysql_fetch_row($result5)) {
$ShowVerseText[$N + 1] = $row[0];
$X = $ShowVerseText[$N + 1];

echo "    <tr>\n";
echo "      <td width=\"700\"><font face=\"Arial\" size=\"2\"><i>$X</i></font></td>\n";
echo "    </tr>\n";
}

echo "  </table>\n";
echo "  </center>\n";
echo "</table>";
}

else {
    // print status message
    echo "No rows found!";
}

User is offlineProfile CardPM
+Quote Post

HowdeeDoodee
RE: Display Results In Only 1 Table W/ 1 Col 1 Row
27 Aug, 2008 - 09:59 AM
Post #3

D.I.C Head
**

Joined: 17 Jun, 2008
Posts: 67

Thank you, Computer. The code works great.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 03:40AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month