Jump to content

Help with form and if statement


KingSpongo

Recommended Posts

Hey all, need a bit of PHP help.

 

I made a table with phpmyadmin that has four fields (id, firstname, lastname, username). I will be displaying this data in a table within a web page. I want to write a script that if the username is empty a text box is shown so I can write it in within the browser. Can I also make it so that when a username cell is empty a submit button is put in an empty cell next to the username. I hope this makes sense.

 

For example the table might look like:

 

IDFirstnameLastnameUsername

1DrewMeloniDMeloni

2PeteHanks[/td]

[td]3

IanParkerIParker

 

Can anyone help me with this or point me to some existing code. I appreciate any help given. Many thanks  :)

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/192722-help-with-form-and-if-statement/
Share on other sites

What about putting another column in the database called 'full' with an int value. When the info is put in there run a check to see if there is a first, last and username. If there is put the value 1 in there if not put 0. Then when echoing it out check that value and if its 0 the echo out that row like a form. Something like the following..

 

<table>

<tr>

<td>

    <form name="myform" action="scriptpage.php" method="post">

    <input type="hidden" name="id" id="id" value="<?=$gotRow['id']?>">

    <input <?php if(trim($gotRow['first'])=="") { echo "type='text'"; } else { "type='hidden'"; } name="first" id="first" value="<?=$gotRow['first']?>"><?=$gotRow['first']?></td></tr>

 

Thats off the top of my head. I have not tried it but I hop you get the point. If not let me know I will try and elaborate a little.

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.