Jump to content

print on two columns


turpentyne

Recommended Posts

I'm working on a site where I've implemented a simple back end wysiwyg editor for content on a page. Then on the public page I run a php query to pull that content and display it. But doing this cancels out the css I have been using to split content into two columns. Is there a way to do this in php, or is there a way to circumvent the problem?  ( also tried echoing the entire css style along with the query result - that didn't work either)

 

The <p id='container_sub'> is what is split into two columns. I tried it outside of the query, and inside the query around where I echo results. Neither worked.

Here's the basic php code, and further down the css that makes two columns:

<?php

$pageid = '2';
  
// Formulate Query
// This is the best way to perform an SQL query
// For more examples, see mysql_real_escape_string()
$query = sprintf("SELECT content FROM tbl_pages WHERE page_id='%s'",
     mysql_real_escape_string($pageid));

// Perform Query
$result = mysql_query($query);

// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die($message);
}

// Use result
// Attempting to print $result won't allow access to information in the resource
// One of the mysql result functions must be used
// See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc.
while ($row = mysql_fetch_assoc($result)) {
    echo "<p id='container_sub'>".$row['content']."</p>";

}

// Free the resources associated with the result set
// This is done automatically at the end of the script
mysql_free_result($result);
      
?>

 

 

The css....

#container_sub {-moz-column-count: 2;
-moz-column-gap: 25px;
-webkit-column-count: 2;
-webkit-column-gap: 20px;
column-count: 2;
column-gap: 20px;}

#container_sub2 {-moz-column-count: 2;
-moz-column-gap: 25px;
-webkit-column-count: 2;
-webkit-column-gap: 20px;
column-count: 2;
column-gap: 20px;}

 

Link to comment
https://forums.phpfreaks.com/topic/258436-print-on-two-columns/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.