netphreak Posted February 9, 2007 Share Posted February 9, 2007 Hi to all, my first post here I am struggeling hard with what millions of php/html beginners must have had difficulties understanding. I've been reading php.net up and down, and searched google for *many* hours the last couple of days. If I knew exactly what to search for... Here's the situation: I have a while loop gathering information from a MySQL table. The output should be outputed in 3 CSS tables. It's almost impossible to get the php output at the right places! It would be so much easier to have the result from the loop available later down my script (after the endwhile;)... Is that possible? As I understand it, php erases all information from memory once it's finished with executing the loop. Meaning I'd have to store it in my script in some way. I've read so much negative about eval(), but will this function be to any help? Any hints on what to read up on is highly valued Link to comment https://forums.phpfreaks.com/topic/37759-output-loop-results-outside-while/ Share on other sites More sharing options...
phil88 Posted February 9, 2007 Share Posted February 9, 2007 I think you're making things more difficult than they need to be. When I output stuff from a mysql table, I just use regular old HTML tables to do the output, like so, echo "<table><tr><td>Col1</td><td>Col2</td><td>Col3</td></tr>"; //Open the table and display the column titles. $query = mysql_query(" SELECT * FROM whatever WHERE cheese = pie "); while($row = mysql_fetch_assoc($query)){ echo "<tr><td>".$row['col1']."</td><td>".$row['Col2']."</td><td>".$row['Col3']."</td></tr>"; // Output each row each time the loop is looped } echo "</table>"; // Close the table Link to comment https://forums.phpfreaks.com/topic/37759-output-loop-results-outside-while/#findComment-180631 Share on other sites More sharing options...
netphreak Posted February 9, 2007 Author Share Posted February 9, 2007 Yes, I know that way of doing it. But I must use CSS instead of html tables. And I know a lot of other examples making this "straight forward" method very "dirty"... Besides, I try to make the html as separated from the php code as possible. Link to comment https://forums.phpfreaks.com/topic/37759-output-loop-results-outside-while/#findComment-180635 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.