Page 1 of 1

Break results into rows

Posted: Fri Jul 10, 2009 9:02 am
by melomonk
Hello

I'm truly a newbie - so be gentle

I'm having trouble getting returned results to display as one row per line
Can someone please show me - tell me - advise me - what i'm not doing to get one row per line
Here are the returned results
http://www.openrealtour.com/test/newfile4.php

Here is the code i'm using

Code: Select all

$rs = mysql_query("SELECT tourid, mls, userid, mls_loc FROM tour") or die ("invalid query");
while ($row = mysql_fetch_assoc($rs)) {
    printf("tourid: %s  mls: %s", "http://URL?=" . $row["tourid"], $row["mls"]);
}
mysql_free_result($rs);

Re: Break results into rows

Posted: Fri Jul 10, 2009 9:17 am
by Skara
1) Output of php is by default html, so you need to add <br /> at the end of your printf.
or
2) If you want this to output as plaintext, add
header('ContentType: text/plain');
to the top of the file and add \n to the end of the printf.

Re: Break results into rows

Posted: Fri Jul 10, 2009 9:33 am
by melomonk
Thank so much Skara
I appreciate your input - IT HELPED!

I used:

Code: Select all

while ($row = mysql_fetch_assoc($rs)) {
 
    printf("tourid: %s  mls: %s", "http://URL?=" . $row["tourid"], $row["mls"]);
    echo "</br>";
}
and got the desired results

Re: Break results into rows

Posted: Fri Jul 10, 2009 10:07 am
by Skara
uh.. it's <br />. There's a space between the r and the / too, btw.

Re: Break results into rows

Posted: Fri Jul 10, 2009 12:08 pm
by McInfo
Skara wrote:2) If you want this to output as plaintext, add
header('ContentType: text/plain');
to the top of the file and add \n to the end of the printf.

Code: Select all

header('Content-Type: text/plain');
//             ^
Edit: This post was recovered from search engine cache.