Jump to content

Modifying Many fields


ballouta

Recommended Posts

Hello,

 

In this question i am not asking for a code, but i am asking about the good techniqe used to do the following.

 

I have books list stored in a table in a database, If I want to view all this list with all its fields and edit what I need to modify and then save the fields.

 

if i am reading one row i would echo them in a form then post all the fields again to update the table.

 

BUT in my case, when i have many rows and each row has many related fields,

e.g:

ISBN  Book_Title  Book_Price    Book_Size etc..

 

How I would know that this Book_Price, Book_Size, Book_Title is for that specific ISBN !?!

In other words, How do I display this list and how do I save it back?

 

thank you

Link to comment
Share on other sites

@laffin

i know the where clause, and i have used it before many times to update tables

 

Actually the point i am trying to take info about is that

when i query those rows from the table and view them,

I am imaging this:

First row:

<input type ='text' name='isbn' value'$row[isbn] />

<input type ='text' name='btitle' value'$row[book_title] />

<input type ='text' name='bsize' value'$row[book_size] />

<input type ='text' name='bprice' value'$row[book_price] />

 

and i still have many many other rows, how i will name those <input>'s so the update is done successfully (this is if i am thinking in a good way).

also same input names...

Thank you

Link to comment
Share on other sites

The input names dun really matter much.

as they are just remapped as $_POST elements keys.

 

but it is all about how u process the $_POST variables.

 

the form input names are just variable names, nothing more

but if yer using just <input type='text'>

u may want to use a foreach statement instead.

 

if yer asking how to reduce the number of variables cuz its getting messy.

you name the form input like a php array

<input type="text" name="book[isbn]">

 

and so on, so when u process the book information, its all in a premade $_POST array

$_POST['book']

 

But forms have no direct relation to how its put into the db. so this question is kinda confusing.

 

 

 

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.