Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-01-2013, 09:04 AM   PM User | #1
amcf1992
Regular Coder

 
Join Date: Jul 2011
Posts: 114
Thanks: 7
Thanked 0 Times in 0 Posts
amcf1992 is an unknown quantity at this point
New line after echoing .$row['column'];

How would I echo a new line after echoing row data

PHP Code:
<?php


mysql_connect
("localhost""root""root") or die(mysql_error());
mysql_select_db("auth") or die(mysql_error());


$result mysql_query("SELECT * FROM users")
or die(
mysql_error());  

$row mysql_fetch_array$result );

echo 
" ID: ".$row['id'];    //would like a new line here
echo " Username: ".$row['username'];   //would like a new line here
echo " Password: ".$row['password'];        //would like a new line here
echo " Email: ".$row['email'];             //would like a new line here
echo " Active Status: ".$row['isactive'];     //would like a new line here
echo " Active Key: ".$row['activekey'];    //would like a new line here
echo " Reset Key: ".$row['resetkey'];      //would like a new line here


?>

Last edited by amcf1992; 02-01-2013 at 09:06 AM..
amcf1992 is offline   Reply With Quote
Old 02-01-2013, 01:54 PM   PM User | #2
tempz
Regular Coder

 
Join Date: Jul 2012
Location: London
Posts: 436
Thanks: 4
Thanked 80 Times in 80 Posts
tempz is an unknown quantity at this point
This put it into a table.

PHP Code:
<?php
$db_host 
'localhost';
$db_user 'user';
$db_pwd 'pass';

$database 'database';
$table 'table';

if (!
mysql_connect($db_host$db_user$db_pwd))
    die(
"Can't connect to database");

if (!
mysql_select_db($database))
    die(
"Can't select database");

// sending query
$result mysql_query("SELECT * FROM {$table}");
if (!
$result) {
    die(
"Query to show fields from table failed");
}

$fields_num mysql_num_fields($result);

echo 
"<p>";
echo 
"<table border='1' class='dataTable'><tr>";
// printing table headers
for($i=0$i<$fields_num$i++)
{
    
$field mysql_fetch_field($result);
    echo 
"<th>{$field->name}</th>";
}
echo 
"</tr>\n";
// printing table rows
while($row mysql_fetch_row($result))
{
    echo 
"<tr>";

    
// $row is array... foreach( .. ) puts every element
    // of $row to $cell variable
    
foreach($row as $cell)
        echo 
"<td>$cell</td>";

    echo 
"</tr>\n";
}
mysql_free_result($result);
?>
tempz is offline   Reply With Quote
Reply

Bookmarks

Tags
echo, php, row

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:52 PM.


Advertisement
Log in to turn off these ads.