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
https://forums.phpfreaks.com/topic/78965-printing-issue/
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
https://forums.phpfreaks.com/topic/78965-printing-issue/#findComment-399605
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
https://forums.phpfreaks.com/topic/78965-printing-issue/#findComment-399626
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
https://forums.phpfreaks.com/topic/78965-printing-issue/#findComment-399633
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.