Page 1 of 1

problem with print and $row

Posted: Sat Nov 04, 2006 6:34 pm
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>";
?>

Re: problem with print and $row

Posted: Sat Nov 04, 2006 7:08 pm
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

Posted: Sat Nov 04, 2006 7:09 pm
by feyd
You have a semicolon after the last closing table cell tag.

Posted: Sat Nov 04, 2006 7:09 pm
by calumstevens
Ok doki, but Im presuming I cant just throw in some <p> tags in between table rows, right?

Posted: Sat Nov 04, 2006 7:11 pm
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.