SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Nov 2009
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Two questoins about PHP

    Hello,

    I was wondering how to print a blank line in PHP. I also was wondering why the code below will not print out just the values, like Roger etc, instead of Array([Name])=>Roger.


    <?
    require_once('mySql.php');

    $mysql=new mySql;
    $mysql->query("select * from Rot");
    while ($row = $mysql->get_assoc()) {
    print_r($row);
    }
    ?>

  2. #2
    SitePoint Member
    Join Date
    Aug 2009
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    to print blank line echo "\r\n"
    i i think print_r() function will not give formatted output because it is just designed to get the content inside for array may be to help coders quickly know without writing loops for array

  3. #3
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was wondering how to print a blank line in PHP.
    In HTML you mean?

  4. #4
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    print_r formats the object into something readable.

    Use

    Code php:
    echo $row->Name;


  5. #5
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Imagining your query is successful, and you want new line in the html source code.

    "select id from Rot"

    PHP Code:
    while ($row $mysql->get_assoc()) {

    echo 
    $row['id'] . PHP_EOL ;

    // uncomment for debug info
    // print_r($row);

    Puts a line end after the $row[0] value.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •