I want to show some mysql results in two different areas...

I thought I would do two queries, and show a certain few (1-5) or whatever on one area, and the rest on another, however I need them split even....

how can I do this?

I thought about doing something like......

if (is_float($counter/2)) $area = "area1"; 
else $area = "area2";

but I don't know. Could I somehow check the amount of rows in a table, split that in half, and show the first half in one area and the rest elsewhere?

If you want to count the number of records in the table, you can use mysql_num_rows.

$query = "select * from tablename";
$result = mysql_query($query);
echo mysql_num_rows($result)." records found...";

If you want the number of columns in a particular table,

$query = "show columns from tablename";
$result = mysql_query($query);
echo mysql_num_rows($result)." columns ...";

As in the above example, once you find out the total rows, you can split it into 2 (or put it in 2 separate arrays and use it wherever you want!).

How about this

<?php 
    $connection = mysql_connect("localhost","root","");
    mysql_select_db("database");
    $page = 0;
    if(isset($_GET['page'])){
        $page = $_GET['page'];
    }else{
        $page = 1;
    }

    $limit = 2;
    $offset = ($page - 1)*$limit;
    $result = mysql_query("select * from table_name limit $offset,$limit;");    
    $get_total = mysql_query("select count(*) as total from table_name ");
    $total_table_name = 0;
    while($h_total = mysql_fetch_array($get_total)){
        $total_table_name = $h_total['total'];
    }   
    $total_page = ceil($total_table_name/$limit);
?>
<div >

        <?php while($data = mysql_fetch_array($result)){ ?>

           <h2><a href="index.php?page=<?php echo $data["table_row"]; ?>" style="text-decoration:none;">
           <?php echo $data["row_to_show"]; ?></a></h2>            

        <?php } ?>  

            <?php if($page > 1){ ?>
            <a href="<?php echo $_SERVER['PHP_SELF']; ?>?page=<?php echo ($page-1); ?>">&lt;&lt;&nbsp;&nbsp;Prev</a>
            <?php 
                }if($page < $total_page){
            ?>

            <a href="<?php echo $_SERVER['PHP_SELF']; ?>?page=<?php echo ($page+1); ?>">Next&nbsp;&nbsp;&gt;&gt;</a>
            <?php } ?>

        <?php mysql_close($koneksi); ?>

</div>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.