1

I want to make a cell's data different in each row of the same column, according to the value of the $row['epilogh']:

<tr>
    <td> <?php echo $row['id']; ?> </td>
    <td> <?php echo $row['epilogh']; ?> </td>
    <td> <?php echo $row['um_username']; ?> </td>
    <td> <?php echo $row['myrole'];?> </td>
    <td> <?php echo $row['request_date'];?> </td>

    <!-- i want the following 2 td to be one and work in the above different cases  -->
    <td style="max-width: 250px; text-align: center;">
    <?php echo '<a href="../make-solemn-declaration-pdf-sec/?id='.$row['id'].'" target="_blank">'.$row['id'].'</a>';?>
                                <form action="../make-solemn-declaration-pdf/?id=<?php echo $id; ?>" method="POST" target="_blank">
                                    <button type="submit" name="btn-pdf">Make a PDF</button>
    </form>
    </td>

    <td style="max-width: 250px">  
        <form method="POST" enctype="multipart/form-data" action="../upload-file/?id=<?php echo $row['id']; ?>">
            <input type="file" name="fileToUpload" id="fileToUpload" accept=".pdf" required />
            <br><hr>
            <input type="submit" name="submit" value="Upload" />
            <? echo "$pdf";?>
        </form>
    </td>

    <td> <a href="../pistop-delete/?id=<?php echo $row['id']; ?>">Delete</a> </td>
</tr>

So let's say that if $row['epilogh'] is 'A' I want a form so a file could be uploaded. On the other hand when $row['epilogh'] is 'B' I want to have a link there for another page. How can I do this?

1
  • You could do it in PHP or MySQL. In MySQL you could construct with a case when statement. In PHP you could just use an if or chained ifs Commented Nov 20, 2021 at 20:04

1 Answer 1

2

if i understand you correctly, you can do this: just use one td:

<td style="max-width: 250px;<?php if($row['epilogh'] == 'A')  echo 'text-align: center;' ?> ">
 <?php
   if($row['epilogh'] == 'A'){
     echo "your upload form"
   }
   else{
     echo "your link to another page"
   }
?>
</td>
Sign up to request clarification or add additional context in comments.

3 Comments

Yes as i see you understand correctly, but i already tried this and it wasn't working because i had a silly mistake! Thank you very much though because with your example i understood it and saw it!
glad to know you understood the problem. if this is your answer then consider choosing it as the correct answer. thanks @Scissors38th
i just missed the double equals in the if clause. i was wondering the whole day but you know... when your head sticks sometimes you cant see the obvious!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.