Jump to content


Photo

Me Again!


  • Please log in to reply
2 replies to this topic

#1 koolgirl

koolgirl
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 01 April 2006 - 11:43 PM

Hi Guys,

Again posting the second part of my question a little bit modified. All I want to do is to get all the fields data from my database in table rows and not plain row by row so that I can change the colors etc of the different fields. I posted once before also a few hours ago(If you want you can scroll down and read that detail also) and was suggested to get a BOOK. Well, I got a bit success now. I do get the data in rows now but not all the fields. I have 3 fields, ID/Name/Email and with the following code I just get the data of two of the mentioned fields in rows:
<html>
<body>
<?php
$db = mysql_connect("xxxxx",
"xxxxx", "xxxxxx");
if (! @mysql_select_db("jokes") ) {
echo( "<P>Unable to locate the " .
"database at this time.</P>" );
exit();
}
$result = mysql_query(
"SELECT ID, Name, Email FROM contacts");
if (!$result) {
echo("<P>Error performing query: " .
mysql_error() . "</P>");
exit();
}
echo "<table width = 100% border=1>\n";
echo "<tr><td>ID</td><td>Name</td><td>Email</td></tr>\n";
while ($myrow = mysql_fetch_row($result)) {
printf("<tr><td>%s </td><td>%s </td><td>%s </td></tr>\n", $myrow[1], $myrow[2],
$myrow[3]);
}
echo "</table>\n";
?>
</body>
</html>
__________________

Yes, I finally got it working some how but still as I said just 2 of the fields can be retrieved in rows. I need help to get all 3 of them in rows and columns so that I can get the display as I want it. Any help would be appreciated other then advising to get a PHP book(I have it already and will get more and am learning just since yesterday So Please, only help in code if possible)

#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 02 April 2006 - 12:03 AM

all arrays (unless otherwise specified) are referenced bginning at 0. so.....

$myrow[0], $myrow[1] amd $myrow[2] shoudl show the info you are expecting.....
follow me on twitter @PHPsycho

#3 koolgirl

koolgirl
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 02 April 2006 - 12:10 AM

Hi Again Guru

Well, Now I can call you GURUUUuuu lol

It is working perfect

Many Thanks





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users