lisa_dmc Posted August 8, 2007 Share Posted August 8, 2007 Hi all, I am really new to php & mysql and I don't have any programming skill, but willing to spend hours of learning before my bedtime. Recently I read about php & mysql a lot, and started to paste code found from the net here and there on my machine and it is very interesting to see the result. I have made a table and create small page to manipulate the data on table (list with add, view and edit, that’s all I can do for now) What I want to know is what are my options if I want certain data on certain row is read only (can not be edit) if a value on a column of that row is... say 1 or 0? Can someone show me where/how to start? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/63858-very-new-to-php-and-like-the-challenge/ Share on other sites More sharing options...
tibberous Posted August 8, 2007 Share Posted August 8, 2007 Hello Lisa. I'm not sure what you asked but I would love to help you out. If you want to talk, my name on aim is tibberous1, or on msn tibberous@hotmail.com, or we can talk here if you prefer. Welcome to the exciting world of PHP! Quote Link to comment https://forums.phpfreaks.com/topic/63858-very-new-to-php-and-like-the-challenge/#findComment-318262 Share on other sites More sharing options...
pranav_kavi Posted August 8, 2007 Share Posted August 8, 2007 Hi, How r u plannin 2 make the rows editable..?? one way is to retrieve all the rows from the table using a query.Then check the value of the column say 'status'.So if status=1,then print the columns of the partcular in textboxes.But if status=0,then print the columns of the row as it is. I hope tis s wat u needed.... Quote Link to comment https://forums.phpfreaks.com/topic/63858-very-new-to-php-and-like-the-challenge/#findComment-318268 Share on other sites More sharing options...
lisa_dmc Posted August 8, 2007 Author Share Posted August 8, 2007 hi all, Thank you for the reply. I am sorry if my question sound confusing. Bassicaly I have a table with ID, Product, ProposedPrice, Approval. So... I also have a list page to manipulate the data. On the list page there is a link to add & edit form to manipulate data on the table. What I am looking for is a way to disable the "edit" feature if value on Approval column is 1. I am not looking for particular code, just some description on how I can accomplish/start learning for that particular issue. or... what syntax I should toy with... tibberous... thank you for the invitation... I prefer to speak here. Quote Link to comment https://forums.phpfreaks.com/topic/63858-very-new-to-php-and-like-the-challenge/#findComment-318278 Share on other sites More sharing options...
pranav_kavi Posted August 8, 2007 Share Posted August 8, 2007 To clear my doubt, R u plannin to have a 'edit' link for each row of the table or just one edit link for the entire list?? I assume the 'add' link is for enitre list. Quote Link to comment https://forums.phpfreaks.com/topic/63858-very-new-to-php-and-like-the-challenge/#findComment-318283 Share on other sites More sharing options...
NArc0t1c Posted August 8, 2007 Share Posted August 8, 2007 so you're table is structured like this: ---------------------------------------- | ID | Product | ProposedPrice | Approval | well, use a normal if statement. You can call all the data, and check while displaying if it's Approval is one. Quote Link to comment https://forums.phpfreaks.com/topic/63858-very-new-to-php-and-like-the-challenge/#findComment-318284 Share on other sites More sharing options...
lisa_dmc Posted August 8, 2007 Author Share Posted August 8, 2007 yess.. my edit link is on every row and my add link is for all the row... Quote Link to comment https://forums.phpfreaks.com/topic/63858-very-new-to-php-and-like-the-challenge/#findComment-318288 Share on other sites More sharing options...
lisa_dmc Posted August 8, 2007 Author Share Posted August 8, 2007 when i call the data i want all the data will be print... even if approved value is 0. so... my thinking.... if i use "if" statement, it can only choose to print data for approve value 1 or 0. am i wrong?? Quote Link to comment https://forums.phpfreaks.com/topic/63858-very-new-to-php-and-like-the-challenge/#findComment-318292 Share on other sites More sharing options...
NArc0t1c Posted August 8, 2007 Share Posted August 8, 2007 Here is an example of what I mean: <?php //Get data from database. $query = mysql_query("SELECT ID, Product, ProposedPrice, Approval FROM table_name"); //The table. echo '<table><tr><th>ID</th><th>Product</th><th>Proposed Price</th><th>Add/Edit</th></tr>'; //Loop trough the data. while ($retrive = mysql_fetch_array($query)){ //Echo first part of data. echo '<tr><td>' . $retrive['ID'] . '</td><td>' . $retrive['Product'] . '</td><td>' . $retrive['ProposedPrice'] . '</td><td>'; //If approval is 1 echo edit link. if ($retrive['Approval'] == 1){ echo '<a herf="edit.php?ID=' . $retrive['ID'] . '">Edit</a>'; //Else echo Not editable. } else { echo 'Not Editable'; } echo '</td></tr>'; } //Close the table. w3 echo '</table>'; ?> Sorry if there is spelling mistypes. Edit: Added notes. Quote Link to comment https://forums.phpfreaks.com/topic/63858-very-new-to-php-and-like-the-challenge/#findComment-318293 Share on other sites More sharing options...
lisa_dmc Posted August 8, 2007 Author Share Posted August 8, 2007 thank you... this forum rockz!!! why didn't i think of those part before... clearly i had a lot to learn... i can see in my head that your code working... I understand the logic if ($retrive['Approval'] == 1){ echo '<a herf="edit.php?ID=' . $retrive['ID'] . '">Edit</a>'; //Else echo Not editable. } else { echo 'Not Editable'; } echo '</td></tr>'; } thank you NArc0t1c & everybody ... i'll toy a bit with your code and get my coding skill improve.. i'll keep my question open for now... in case there's other way of doing it... Quote Link to comment https://forums.phpfreaks.com/topic/63858-very-new-to-php-and-like-the-challenge/#findComment-318311 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.