Page 1 of 1

Easy Question

Posted: Sat Feb 19, 2005 9:15 pm
by rdionne1187

Code: Select all

$connect=mysql_connect('localhost', 'clanhost_frgn1', 'dumbo5');
  if(!$connect){
        die('unable to connect to mysql server');
  }
  echo "connected..."."<br>";
  mysql_select_db("clanhost_frgn1", $connect);
  $query="SELECT Part_Name FROM `orders`";
  $result=mysql_query($query) or die("unable to retrieve pn: ".mysql_error()."<br>");
  $row = mysql_fetch_array($result);
  foreach($row as $value)&#123;
    print($value."<br>");
  &#125;
  
mysql_close($connect);
basically, I'm trying to get the contents of this table, and print them, but it just prints

Code: Select all

connected...
Chain
Chain
where the first item in the table of Part_number is chain, and the second one doesn't get printed? it just prints the first one twice.

Posted: Sat Feb 19, 2005 9:34 pm
by feyd
mysql_fetch_array() returns both numeric and named fields, this explains the two of the same. The other part is, mysql_fetch_array() only returns 1 record found at a time. You need a loop.

Posted: Mon Feb 21, 2005 2:32 pm
by rdionne1187
I am extremely new to mysql, thank you