Jump to content

Recommended Posts

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.

 

Link to comment
https://forums.phpfreaks.com/topic/63858-very-new-to-php-and-like-the-challenge/
Share on other sites

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

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.

 

 

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.

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.

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

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.