KingSpongo Posted February 20, 2010 Share Posted February 20, 2010 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]3IanParkerIParker Can anyone help me with this or point me to some existing code. I appreciate any help given. Many thanks Quote Link to comment Share on other sites More sharing options...
jorley Posted February 20, 2010 Share Posted February 20, 2010 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. Quote Link to comment Share on other sites More sharing options...
KingSpongo Posted February 20, 2010 Author Share Posted February 20, 2010 Thanks for the reply Jorley, I tried what you said but I'm having problems with adding the 1's and 0's into the new column. Can anyone tell me how to do this automatically instead of manually adding them in myself? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.