Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
Cómo multiplicar variables de PHP en este bucle for

Obtengo valores de un formulario y trato de multiplicarlos con valores en el lado izquierdo incrementados en 5s. Agregué una imagen de los resultados también.

Código:

 <?php if ($_SERVER["REQUEST_METHOD"] == "GET") { $costOne = trim($_GET["c1"]); $costTwo = trim($_GET["c2"]); $costThree = trim($_GET["c3"]); $costFour = trim($_GET["c4"]); $costFive = trim($_GET["c5"]); $minimum = trim($_GET["min"]); $maximum = trim($_GET["max"]); } echo '<table>'; echo '<tr>'; echo '<th>Cost per person<br>Party size</th>'; echo "<th>$costOne</th>"; echo "<th>$costTwo</th>"; echo "<th>$costThree</th>"; echo "<th>$costFour</th>"; echo "<th>$costFive</th>"; echo '</tr>'; for ($col=$minimum; $col <= $maximum; $col+=5) { echo "<tr>"; echo "<td>$col</td>"; echo "<td>$col*$costOne</td>"; echo "<td>$col*$costTwo</td>"; echo "<td>$col*$costThree</td>"; echo "<td>$col*$costFour</td>"; echo "<td>$col*$costFive</td>"; echo "</tr>"; } echo '</table>'; ?>

Resultado

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Prueba esto:

 for ($col=$minimum; $col <= $maximum; $col+=5) { echo "<tr>"; echo "<td>" .$col. "</td>"; echo "<td>" .$col*$costOne. "</td>"; echo "<td>" .$col*$costTwo. "</td>"; echo "<td>" .$col*$costThree. "</td>"; echo "<td>" .$col*$costFour. "</td>"; echo "<td>" .$col*$costFive. "</td>"; echo "</tr>"; }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!