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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.