problem with print and $row

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
calumstevens
Forum Commoner
Posts: 25
Joined: Mon Oct 23, 2006 5:16 am

problem with print and $row

Post by calumstevens »

Ok, I'm trying to take the customerID from my database and then include it in the link to my next page. The below code works, but I dont know the print function well enough to modify it. As it is, that prints out my records all on one line and all squashed together, not very attractive :)

If someone with good knowledge of the print function could show me how to display the data logically with a coresponding label whilst preserving the current functionality that would be fantastic. The records, in the order theyre queried, are shown below.

Customer ID First Name Surname User Name Email Password

Thanks in advance for any help people.

Code: Select all

//Fetch each of the query rows in $result array 
while ($row = @ mysql_fetch_array($result)) 
{ 
// Print one row of results 
print "<tr>" . 
"<td>" . $row["CustomerID"] . "</td>" . 

"<td>" . $row["Firstnames"] . "</td>" . 
"<td>" . $row["Surname"] . "</td>" . 
"<td>" . $row["Username"] . "</td>" . 
"<td>" . $row["Email"] . "</td>" . 
"<td>" . $row["Password"] . "</td>" . 
//print a change/delete link at the end of each row
"<td><a href=editdetails.php?id=".$row[0].">Change/Delete</a></td>"; 
"</tr>"; 
} 
// Then, finish the table
print "</table>";
?>
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: problem with print and $row

Post by Zoxive »

calumstevens wrote:If someone with good knowledge of the print function could show me how to display the data logically with a coresponding label whilst preserving the current functionality that would be fantastic. The records, in the order theyre queried, are shown below.
There isn't anything more to the "print" function then what it does, which is print.

All print is doing is printing text/html. (Default Header)

So all you have to do is style what you print out with html, or even style sheets.

-Zoxive
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You have a semicolon after the last closing table cell tag.
calumstevens
Forum Commoner
Posts: 25
Joined: Mon Oct 23, 2006 5:16 am

Post by calumstevens »

Ok doki, but Im presuming I cant just throw in some <p> tags in between table rows, right?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

calumstevens wrote:Ok doki, but Im presuming I cant just throw in some <p> tags in between table rows, right?
No tags may be between table rows.
Post Reply