Write a PHP function (write the function only) to dynamically create a.docx

D

Write a PHP function (write the function only) to dynamically create an HTML table with m rows and n columns. m and n are function parameters. Other requirements: - Each column is 100 in width - The table and all cells should have visible borders - In each cell, please display the value of m and n aligned to the center. Solution function create_table($data) { $res = \'<table width=\"200\" border=\"1\">\'; $max_data = sizeof($data); $ctr = 1; foreach ($data as $db_data) { if ($ctr % 2 == 0) $res .= \'<td align=\"center\">\' . $db_data[\'id\']. \'</td></tr>\'; else { if ($ctr < $max_data) $res .= \'<tr><td align=\"center\">\' . $db_data[\'id\']. \'</td>\'; else $res .= \'<tr><td colspan=\"2\" align=\"center\">\' . $db_data[\'id\']. \'</td></tr>\'; } $ctr++; } return $res . \'</table>\'; } .

Write a PHP function (write the function only) to dynamically create an HTML table with m
rows and n columns. m and n are function parameters. Other requirements: - Each column is 100
in width - The table and all cells should have visible borders - In each cell, please display the
value of m and n aligned to the center.
Solution
function create_table($data) {
$res = '<table width="200" border="1">';
$max_data = sizeof($data);
$ctr = 1;
foreach ($data as $db_data) {
if ($ctr % 2 == 0) $res .= '<td align="center">' . $db_data['id']. '</td></tr>';
else {
if ($ctr < $max_data) $res .= '<tr><td align="center">' . $db_data['id']. '</td>';
else $res .= '<tr><td colspan="2" align="center">' . $db_data['id']. '</td></tr>';
}
$ctr++;
}
return $res . '</table>';
}

Recommended

Write a SIMPLE java program to print out the numbers from 100 to 1- wi.docx by
Write a SIMPLE java program to print out the numbers from 100 to 1- wi.docxWrite a SIMPLE java program to print out the numbers from 100 to 1- wi.docx
Write a SIMPLE java program to print out the numbers from 100 to 1- wi.docxdrosa1
29 views2 slides
Write a simple c++ program that computes the value of ex by using the.docx by
Write a simple c++ program that computes the value of ex by using the.docxWrite a simple c++ program that computes the value of ex by using the.docx
Write a simple c++ program that computes the value of ex by using the.docxdrosa1
12 views1 slide
Write a short assembly language module to be used with C++ that rotate.docx by
Write a short assembly language module to be used with C++ that rotate.docxWrite a short assembly language module to be used with C++ that rotate.docx
Write a short assembly language module to be used with C++ that rotate.docxdrosa1
2 views2 slides
Write a short essay- between 400 and 500 words- responding to the assi.docx by
Write a short essay- between 400 and 500 words- responding to the assi.docxWrite a short essay- between 400 and 500 words- responding to the assi.docx
Write a short essay- between 400 and 500 words- responding to the assi.docxdrosa1
3 views1 slide
Write a SELECT statement that returns the LastName and JobTitle of eac.docx by
Write a SELECT statement that returns the LastName and JobTitle of eac.docxWrite a SELECT statement that returns the LastName and JobTitle of eac.docx
Write a SELECT statement that returns the LastName and JobTitle of eac.docxdrosa1
6 views1 slide
Write a recursive C function that counts the number of vowels in a str.docx by
Write a recursive C function that counts the number of vowels in a str.docxWrite a recursive C function that counts the number of vowels in a str.docx
Write a recursive C function that counts the number of vowels in a str.docxdrosa1
7 views2 slides

More Related Content

More from drosa1

Write a recursive function to convert a character string of digits to.docx by
Write a recursive function to convert a character string of digits to.docxWrite a recursive function to convert a character string of digits to.docx
Write a recursive function to convert a character string of digits to.docxdrosa1
5 views2 slides
Write a query to display the customer last name and city for all custo.docx by
Write a query to display the customer last name and city for all custo.docxWrite a query to display the customer last name and city for all custo.docx
Write a query to display the customer last name and city for all custo.docxdrosa1
3 views2 slides
write a program that reads package weights and calculate the post fee.docx by
write a program that reads package weights and calculate the post fee.docxwrite a program that reads package weights and calculate the post fee.docx
write a program that reads package weights and calculate the post fee.docxdrosa1
2 views2 slides
Write a program that takes an input of n and prints the numbers from 1.docx by
Write a program that takes an input of n and prints the numbers from 1.docxWrite a program that takes an input of n and prints the numbers from 1.docx
Write a program that takes an input of n and prints the numbers from 1.docxdrosa1
2 views2 slides
Write a program to compute the volume V of a cylinder of radius r and (1).docx by
Write a program to compute the volume V of a cylinder of radius r and (1).docxWrite a program to compute the volume V of a cylinder of radius r and (1).docx
Write a program to compute the volume V of a cylinder of radius r and (1).docxdrosa1
2 views1 slide
Write a program in assembly language that will test PIN #0 of PORTA to.docx by
Write a program in assembly language that will test PIN #0 of PORTA to.docxWrite a program in assembly language that will test PIN #0 of PORTA to.docx
Write a program in assembly language that will test PIN #0 of PORTA to.docxdrosa1
4 views2 slides

More from drosa1(20)

Write a recursive function to convert a character string of digits to.docx by drosa1
Write a recursive function to convert a character string of digits to.docxWrite a recursive function to convert a character string of digits to.docx
Write a recursive function to convert a character string of digits to.docx
drosa15 views
Write a query to display the customer last name and city for all custo.docx by drosa1
Write a query to display the customer last name and city for all custo.docxWrite a query to display the customer last name and city for all custo.docx
Write a query to display the customer last name and city for all custo.docx
drosa13 views
write a program that reads package weights and calculate the post fee.docx by drosa1
write a program that reads package weights and calculate the post fee.docxwrite a program that reads package weights and calculate the post fee.docx
write a program that reads package weights and calculate the post fee.docx
drosa12 views
Write a program that takes an input of n and prints the numbers from 1.docx by drosa1
Write a program that takes an input of n and prints the numbers from 1.docxWrite a program that takes an input of n and prints the numbers from 1.docx
Write a program that takes an input of n and prints the numbers from 1.docx
drosa12 views
Write a program to compute the volume V of a cylinder of radius r and (1).docx by drosa1
Write a program to compute the volume V of a cylinder of radius r and (1).docxWrite a program to compute the volume V of a cylinder of radius r and (1).docx
Write a program to compute the volume V of a cylinder of radius r and (1).docx
drosa12 views
Write a program in assembly language that will test PIN #0 of PORTA to.docx by drosa1
Write a program in assembly language that will test PIN #0 of PORTA to.docxWrite a program in assembly language that will test PIN #0 of PORTA to.docx
Write a program in assembly language that will test PIN #0 of PORTA to.docx
drosa14 views
Write a program that uses a dynamic array that contains 5 items of dou (1).docx by drosa1
Write a program that uses a dynamic array that contains 5 items of dou (1).docxWrite a program that uses a dynamic array that contains 5 items of dou (1).docx
Write a program that uses a dynamic array that contains 5 items of dou (1).docx
drosa12 views
Write a program that calculates the final value of a ten year- $10-000 (1).docx by drosa1
Write a program that calculates the final value of a ten year- $10-000 (1).docxWrite a program that calculates the final value of a ten year- $10-000 (1).docx
Write a program that calculates the final value of a ten year- $10-000 (1).docx
drosa12 views
Write a program that finds the temperature- as an integer - that is th.docx by drosa1
Write a program that finds the temperature- as an integer - that is th.docxWrite a program that finds the temperature- as an integer - that is th.docx
Write a program that finds the temperature- as an integer - that is th.docx
drosa12 views
Write a python program that opens the career-txt file that is included.docx by drosa1
Write a python program that opens the career-txt file that is included.docxWrite a python program that opens the career-txt file that is included.docx
Write a python program that opens the career-txt file that is included.docx
drosa12 views
Write a program that contains and utilizes a function called haltNum(i.docx by drosa1
Write a program that contains and utilizes a function called haltNum(i.docxWrite a program that contains and utilizes a function called haltNum(i.docx
Write a program that contains and utilizes a function called haltNum(i.docx
drosa12 views
Write a program in MATLAB to implement the algorithm of Gaussian Elimi.docx by drosa1
Write a program in MATLAB to implement the algorithm of Gaussian Elimi.docxWrite a program in MATLAB to implement the algorithm of Gaussian Elimi.docx
Write a program in MATLAB to implement the algorithm of Gaussian Elimi.docx
drosa13 views
write a program to calculate the average of six number input by the us.docx by drosa1
write a program to calculate the average of six number input by the us.docxwrite a program to calculate the average of six number input by the us.docx
write a program to calculate the average of six number input by the us.docx
drosa17 views
Write a program that uses the DrawingPanel to produces the following f.docx by drosa1
Write a program that uses the DrawingPanel to produces the following f.docxWrite a program that uses the DrawingPanel to produces the following f.docx
Write a program that uses the DrawingPanel to produces the following f.docx
drosa12 views
Write a program in assembly language 8086 not 8085 to find the number.docx by drosa1
Write a program in assembly language 8086 not 8085 to find the number.docxWrite a program in assembly language 8086 not 8085 to find the number.docx
Write a program in assembly language 8086 not 8085 to find the number.docx
drosa17 views
write a mips code which pop-ups a confirmation dialog which have yes o.docx by drosa1
write a mips code which pop-ups a confirmation dialog which have yes o.docxwrite a mips code which pop-ups a confirmation dialog which have yes o.docx
write a mips code which pop-ups a confirmation dialog which have yes o.docx
drosa110 views
Write a program in (C or C++ or Java or python) to capture the center.docx by drosa1
Write a program in (C or C++ or Java or python) to capture the center.docxWrite a program in (C or C++ or Java or python) to capture the center.docx
Write a program in (C or C++ or Java or python) to capture the center.docx
drosa12 views
write a new equation of the line in slope intercept form parallel to e.docx by drosa1
write a new equation of the line in slope intercept form parallel to e.docxwrite a new equation of the line in slope intercept form parallel to e.docx
write a new equation of the line in slope intercept form parallel to e.docx
drosa15 views
Write a program file_max-c that reads a set of integer numbers from a.docx by drosa1
Write a program file_max-c that reads a set of integer numbers from a.docxWrite a program file_max-c that reads a set of integer numbers from a.docx
Write a program file_max-c that reads a set of integer numbers from a.docx
drosa13 views
Write a PASCAL program to compare two integers entered from the keyboa.docx by drosa1
Write a PASCAL program to compare two integers entered from the keyboa.docxWrite a PASCAL program to compare two integers entered from the keyboa.docx
Write a PASCAL program to compare two integers entered from the keyboa.docx
drosa155 views

Recently uploaded

When Sex Gets Complicated: Porn, Affairs, & Cybersex by
When Sex Gets Complicated: Porn, Affairs, & CybersexWhen Sex Gets Complicated: Porn, Affairs, & Cybersex
When Sex Gets Complicated: Porn, Affairs, & CybersexMarlene Maheu
67 views73 slides
11.28.23 Social Capital and Social Exclusion.pptx by
11.28.23 Social Capital and Social Exclusion.pptx11.28.23 Social Capital and Social Exclusion.pptx
11.28.23 Social Capital and Social Exclusion.pptxmary850239
298 views25 slides
Sociology KS5 by
Sociology KS5Sociology KS5
Sociology KS5WestHatch
70 views23 slides
Collective Bargaining and Understanding a Teacher Contract(16793704.1).pptx by
Collective Bargaining and Understanding a Teacher Contract(16793704.1).pptxCollective Bargaining and Understanding a Teacher Contract(16793704.1).pptx
Collective Bargaining and Understanding a Teacher Contract(16793704.1).pptxCenter for Integrated Training & Education
93 views57 slides
Recap of our Class by
Recap of our ClassRecap of our Class
Recap of our ClassCorinne Weisgerber
77 views15 slides
Psychology KS4 by
Psychology KS4Psychology KS4
Psychology KS4WestHatch
84 views4 slides

Recently uploaded(20)

When Sex Gets Complicated: Porn, Affairs, & Cybersex by Marlene Maheu
When Sex Gets Complicated: Porn, Affairs, & CybersexWhen Sex Gets Complicated: Porn, Affairs, & Cybersex
When Sex Gets Complicated: Porn, Affairs, & Cybersex
Marlene Maheu67 views
11.28.23 Social Capital and Social Exclusion.pptx by mary850239
11.28.23 Social Capital and Social Exclusion.pptx11.28.23 Social Capital and Social Exclusion.pptx
11.28.23 Social Capital and Social Exclusion.pptx
mary850239298 views
Sociology KS5 by WestHatch
Sociology KS5Sociology KS5
Sociology KS5
WestHatch70 views
Psychology KS4 by WestHatch
Psychology KS4Psychology KS4
Psychology KS4
WestHatch84 views
Class 10 English notes 23-24.pptx by TARIQ KHAN
Class 10 English notes 23-24.pptxClass 10 English notes 23-24.pptx
Class 10 English notes 23-24.pptx
TARIQ KHAN131 views
Are we onboard yet University of Sussex.pptx by Jisc
Are we onboard yet University of Sussex.pptxAre we onboard yet University of Sussex.pptx
Are we onboard yet University of Sussex.pptx
Jisc96 views
Drama KS5 Breakdown by WestHatch
Drama KS5 BreakdownDrama KS5 Breakdown
Drama KS5 Breakdown
WestHatch79 views
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant... by Ms. Pooja Bhandare
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...
PLASMA PROTEIN (2).pptx by MEGHANA C
PLASMA PROTEIN (2).pptxPLASMA PROTEIN (2).pptx
PLASMA PROTEIN (2).pptx
MEGHANA C68 views
EIT-Digital_Spohrer_AI_Intro 20231128 v1.pptx by ISSIP
EIT-Digital_Spohrer_AI_Intro 20231128 v1.pptxEIT-Digital_Spohrer_AI_Intro 20231128 v1.pptx
EIT-Digital_Spohrer_AI_Intro 20231128 v1.pptx
ISSIP369 views
Scope of Biochemistry.pptx by shoba shoba
Scope of Biochemistry.pptxScope of Biochemistry.pptx
Scope of Biochemistry.pptx
shoba shoba133 views
Solar System and Galaxies.pptx by DrHafizKosar
Solar System and Galaxies.pptxSolar System and Galaxies.pptx
Solar System and Galaxies.pptx
DrHafizKosar91 views
11.30.23 Poverty and Inequality in America.pptx by mary850239
11.30.23 Poverty and Inequality in America.pptx11.30.23 Poverty and Inequality in America.pptx
11.30.23 Poverty and Inequality in America.pptx
mary850239160 views
Dance KS5 Breakdown by WestHatch
Dance KS5 BreakdownDance KS5 Breakdown
Dance KS5 Breakdown
WestHatch79 views
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively by PECB
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks EffectivelyISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively
PECB 585 views
UWP OA Week Presentation (1).pptx by Jisc
UWP OA Week Presentation (1).pptxUWP OA Week Presentation (1).pptx
UWP OA Week Presentation (1).pptx
Jisc88 views

Write a PHP function (write the function only) to dynamically create a.docx

  • 1. Write a PHP function (write the function only) to dynamically create an HTML table with m rows and n columns. m and n are function parameters. Other requirements: - Each column is 100 in width - The table and all cells should have visible borders - In each cell, please display the value of m and n aligned to the center. Solution function create_table($data) { $res = '<table width="200" border="1">'; $max_data = sizeof($data); $ctr = 1; foreach ($data as $db_data) { if ($ctr % 2 == 0) $res .= '<td align="center">' . $db_data['id']. '</td></tr>'; else { if ($ctr < $max_data) $res .= '<tr><td align="center">' . $db_data['id']. '</td>'; else $res .= '<tr><td colspan="2" align="center">' . $db_data['id']. '</td></tr>'; } $ctr++; } return $res . '</table>'; }