Jump to content

printing issue


sayedsohail

Recommended Posts

Hi everyone,

 

I had to print decription on a pre-printed form against items in a serial number on a specific postion i.e,

 

Pre-printe form

 

Serial Number    Description
1.1                  if($row['title']=='1.1'){ echo "$row['description']";}
1.2                  if($row['title']=='1.2'){ echo "$row['description']";}
2.1                  if($row['title']=='2.1'){ echo "$row['description']";}
2.1                  if($row['title']=='2.2'){ echo "$row['description']";}
3.1                  if($row['title']=='3.1'){ echo "$row['description']";}
3.2                  if($row['title']=='3.2'){ echo "$row['description']";}
4.1                  if($row['title']=='4.1'){ echo "$row['description']";}
4.2                  if($row['title']=='4.2'){ echo "$row['description']";}

 

Can someone suggest any better method than this. 

 

Please advise.

 

Thanks,

Link to comment
Share on other sites

Well...you are using more if statements than you need to, you only need one since you are doing the same thing for each one.

 

<?php

if ($row['title'] == '1.1' || $row['title'] == '1.2' || $row['title'] == '2.1' || 
$row['title'] == '2.2' || ...and so on){

   echo $row['description'];

}

?>

 

Link to comment
Share on other sites

yes there is a pattern, titles in sequential order an the description should print against this order.  the $row['title'] and $row['descriptiion'].  But it is not necessary that data comes in sequential order, therefore i need to use if statment to see if there is any matching titles and than print on specific location row 1 to row 50 so on.

 

1.1

1.2

1.3

1.4

1.5

2.1

2.2

2.3

2.4

2.5

3.1

3.2

3.3

3.4

3.5

4.1

4.2

4.3

4.4

4.5

 

Thanks,

Link to comment
Share on other sites

this is the output of html table

 

Serial Number    Description

1.1                  xyz

1.2                 

2.1                 

2.1                 

3.1                 

3.2                 

4.1                 

4.2                 

 

so on.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.