eashton123 Posted March 31, 2009 Share Posted March 31, 2009 Basically what I am looking to do is generate a form with a whole bunch of text fields in it. These text fields will go into a database on submit. Pretty basic. But the person is only allowed to put text into a text field once and once that data is submit. The text field changes to read only and displays the data entered. Allowing that person to only submit data for that field once. What I was thinking was an IF statement but i have run into a dead end because the IF statement only works if there is something in the database already. Thanks $dbLink = mysql_connect($dbHost, $dbUser, $dbPass); $clientname = $_POST["ClientNamefour"]; $sql = sprintf("SELECT Activity_Code, Date_Time, Client_Units, Time_Stamp FROM transaction WHERE Employee_Code='num' AND Client_Code='%s'", mysql_real_escape_string($clientname)); $result = mysql_db_query ($dbName, $sql, $dbLink); while ($row=mysql_fetch_array($result)) { $PRtime = $row["Time_Stamp"]; $PRDate = $row["Date_Time"]; $PRactivitycode = $row["Activity_Code"]; $PRYear = substr($PRDate, 0, 4); $PRMonth = substr($PRDate, 5, 2); $PRDay = substr($PRDate, 8, 2); $actualYear = date("Y"); $actualDay = date("d"); $actualMonth = date("m"); if ($PRYear == $actualYear && $PRDay == $actualDay && $PRtime == '12:36 PM' && $PRactivitycode =! '0' ){ echo "<br>Client Number: $clientname"; echo "<table> <tr><td>Activity Code</td><td>Pieces</td></tr> <tr><td><input name='txtActivitycode1' type='text' class='textboxBorder' id='txtActivitycode1' size='6' value='$row[Activity_Code]' maxlength='6' readonly> </td><td><input name='txtunits' type='text' class='textboxBorder' id='txtunits' size='5' value='$row[Client_Units]' maxlength='5'> </td></tr></table>"; } if ($PRYear == $actualYear && $PRDay == $actualDay && $PRtime == '12:36 PM' && $PRactivitycode == '0' ){ echo "Activity Code: <input name='txtActivitycode' type='text' class='textboxBorder' id='txtActivitycode' size='6' maxlength='6'> Pieces: <input name='txtunits' type='text' class='textboxBorder' id='txtunits' size='5' maxlength='5'><br>"; }else{ echo "Activity Code: <input name='txtActivitycode2' type='text' class='textboxBorder' id='txtActivitycode2' size='6' maxlength='6'> Pieces: <input name='txtunits2' type='text' class='textboxBorder' id='txtunits2' size='5' maxlength='5'><br>"; exit; } } ?> Link to comment https://forums.phpfreaks.com/topic/151938-php-code-help-please/ Share on other sites More sharing options...
lonewolf217 Posted March 31, 2009 Share Posted March 31, 2009 so basically once the form is submitted you want to show the form with the data they entered, but in readonly format ? basically you use this <input type="text" name="username" value="<?php echo $row['username']; ?>" DISABLED> Link to comment https://forums.phpfreaks.com/topic/151938-php-code-help-please/#findComment-797899 Share on other sites More sharing options...
eashton123 Posted March 31, 2009 Author Share Posted March 31, 2009 Well not exactly. What I would like to see happen is this. my form 8:00am textfield textfield 8:15am textfield textfield 8:30am 123123 1231231 Say the user fills in 8:30am fills in the two texts fields with whatever. Once they hit submit I don't want them to be able to submit another entry for 8:30am so i want the two text fields to turn to read only. But the user would still be allowed to enter in information for the 8:00am or the 8:15am Link to comment https://forums.phpfreaks.com/topic/151938-php-code-help-please/#findComment-797913 Share on other sites More sharing options...
lonewolf217 Posted March 31, 2009 Share Posted March 31, 2009 its still the same idea. when you are outputting the form, you pull the data from the database. if that timestamp has data already inputted, then disable the input. the value will still show, but it will be read only Link to comment https://forums.phpfreaks.com/topic/151938-php-code-help-please/#findComment-797917 Share on other sites More sharing options...
eashton123 Posted March 31, 2009 Author Share Posted March 31, 2009 Copy and pasted the wrong if statements if ($PRYear == $actualYear && $PRDay == $actualDay && $PRtime == '12:37 PM' && $PRactivitycode =! '0' ){ echo "<table> <tr><td>Activity Code</td><td>Pieces</td></tr> <tr><td><input name='txtActivitycode1' type='text' class='textboxBorder' id='txtActivitycode2' size='6' value='$row[Activity_Code]' maxlength='6' readonly> </td><td><input name='txtunits' type='text' class='textboxBorder' id='txtunits' size='5' value='$row[Client_Units]' maxlength='5'> </td></tr></table>"; exit; }else{ echo "Activity Code: <input name='txtActivitycode2' type='text' class='textboxBorder' id='txtActivitycode2' size='6' maxlength='6'> Pieces: <input name='txtunits2' type='text' class='textboxBorder' id='txtunits2' size='5' maxlength='5'><br>"; exit; Link to comment https://forums.phpfreaks.com/topic/151938-php-code-help-please/#findComment-797919 Share on other sites More sharing options...
eashton123 Posted March 31, 2009 Author Share Posted March 31, 2009 Right but how would I do that. How would the code look because right now i have it to were the text fields only show up if the IF statement is correct. How would I make it so that normally it shows up with the text fields editable, but then if the IF statement is true it changes it to read only? Link to comment https://forums.phpfreaks.com/topic/151938-php-code-help-please/#findComment-797921 Share on other sites More sharing options...
eashton123 Posted March 31, 2009 Author Share Posted March 31, 2009 bump anyone with suggestions? Link to comment https://forums.phpfreaks.com/topic/151938-php-code-help-please/#findComment-798032 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.