Jump to content


Photo

How not to print the array?


  • Please log in to reply
1 reply to this topic

#1 crazylegseddie

crazylegseddie
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 12 April 2006 - 07:07 PM

hey simple question. I use this to print out a specific row from my database shown below:

<?php
require '../library/config.php';
$result = mysql_query('SELECT pd_more FROM tbl_product WHERE pd_id = ' . $_GET['pd_id']) or exit(mysql_error());
$row = mysql_fetch_assoc($result);
print_r($row);
?>

But when it prints the information it includes this: Array ( [pd_more] => This is test data ). How do i change the script so it only prints the text: This is test data

Thank you whoever can help me with this??

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 12 April 2006 - 07:16 PM

That's what the print_r() function does, it dumps the array and the variable $row is an array. To just pring the value, do
<?php echo $row['pd_more']; ?>

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users