More efficient way

I know this isn’t the most efficient way of polling the database but I can’t think of a better way without asking for help so please help.
I want to poll the database and output the content in chunks of 3 then 4.
See code for display. Database structure is included as well. Thanks!

<div id="services">
$service_result1 = mysql_query("SELECT * FROM ".$db_prefix."services WHERE id='1'");
$service_data1 =  mysql_fetch_array($service_result1);
    <dd><p><? echo $service_data1['explaination']; ?></p></dd>
$service_result2 = mysql_query("SELECT * FROM ".$db_prefix."services WHERE id='2'");
$service_data2 =  mysql_fetch_array($service_result2);
    <dd><p><? echo $service_data2['explaination'];?></p></dd>
    <dt>Production Assistance</dt>
$service_result3 = mysql_query("SELECT * FROM ".$db_prefix."services WHERE id='3'");
$service_data3 =  mysql_fetch_array($service_result3);
    <dd><p><? echo $service_data3['explaination'];?></p></dd>

The second batch is the same output only I’m looking at pulling 4 services from the database instead of 3, this kind of setup would poll the database 7 times every time the page was loaded. I know it’s not right but need some help.
Here is the database structure for services.

  `title` varchar(100) NOT NULL,
  `explaination` text NOT NULL,
  UNIQUE KEY `id` (`id`)

The id and title don’t change via an update script and are not deleted so they stay as they are.

I know that I can setup the select statement to only select 3 with a LIMIT 3 but I wouldn’t know how to start selecting again from 4-7. If that helps I do know about the LIMIT statement.

would using offset as well help?

That might work to decrease the amount of database calls.
How about some help in creating a while statement that would set a variable $service_explaination[1-7] from a single select statement and I just echo the array variable in the area I need to put it. Will that work and how do I do it?

What about this then to set up your array?


$service_explanation = array();

$query = 'select explanation from tableName';
$rs = mysql_query($query,$conn);

while($row=mysql_fetch_assoc($rs)) {
      $service_explanation[] = $row['explanation'];


Outstanding! Perfect, just what I wanted, once again I have learned something today and I know a new way to pull a bunch of information from the database one row at a time. Thanks!