Shawn I found this in the archives of the mailing list, hope this helps.
i didn't write it so I can't answer any questions about it. I didn't add
it to the FAQ because I wasn't sure if it was finished/correct.
-------------
Hi!
OK, Here is the HOW-TO I made. I do have a feeling there is something I
have
forgotten, but I can not remember for sure. I hope this one is correct
now. Please
notefy me if there are any errors. It is so nice to have next time I need
to do this.
I know for sure that the search results screen is forgotten, but that
shuld be easy to
do. You must read all files because I am sure there is a small section
forgotten
somewhere in one of the screens or something.
Most of the work is just reading the code, adding new lines to the code
allready
there.
I found the project wery educational :-))
How to add more fields in item table
These fields had to be altered:
1. Build.sql
2. From /modules/action/ I had to add to
A. ADD_ITEM
B. UPDATE_ITEM
3 In /modules/screens these 3
A. item
B. add_item
C. admin_item
1. Build.sql
The filds had to be added.
CREATE TABLE item (
ID int(11) NOT NULL AUTO_INCREMENT,
Name varchar(255),
FirstName varchar(255),#this
LastName varchar(255), #this
Title varchar(255), #this
ReleaseDate date, #and this was added.
2. From /modules/action/ I had to add to
A. ADD_ITEM
B. UPDATE_ITEM
A. In ADD_ITEM I just inserted new fields in insert statment and dublicate
lines with
new names for valiues
/*
** Add item record.
*/
if ($continueScript) # Added the new field to insert statement
{
$Query = "INSERT INTO item (Name, FirstName, LastName, Title,
ReleaseDate, " .
"Description, Keywords, Thumbnail, Graphic, LargeGraphic,
DisplayPrecedence, " .
"Active) ";
$Query .= "VALUES (";
$Query .= "'" . addslashes($inputName) . "', "; #This- all dublicate
lines
$Query .= "'" . addslashes($inputFirstName) . "', ";#This
$Query .= "'" . addslashes($inputLastName) . "', ";#This
$Query .= "'" . addslashes($inputTitle) . "', ";
$Query .= "'" . addslashes($inputReleaseDate) . "', ";
B. In UPPDATE_ITEM
/*
** Update the item's main information.
*/
if ($continueScript)
{
$Query = "UPDATE item ";
$Query .= "SET Name='" . addslashes($inputName) . "', "; #This on has
SET
$Query .= "FirstName='" . addslashes($inputFirstName) . "', ";#New
$Query .= "LastName='" . addslashes($inputLastName) . "', ";#New
$Query .= "Title='" . addslashes($inputTitle) . "', ";#New
$Query .= "ReleaseDate='" . addslashes($inputReleaseDate) . "', ";#New
And in /modules/include I had to add to
A. item_functions
//Get main item information# Added the new fields to start of select
statement
$Query = "SELECT Name, FirstName, LastName, Title, ReleaseDate,
Description,
Keywords, Graphic, LargeGraphic, Thumbnail ";
$Query .= "FROM item ";
$Query .= "WHERE ID = $Item_ID ";
$Query .= "AND Active = 'Y'";
$DatabaseResult = mysql_query($Query, $DatabaseLink);
if(mysql_num_rows($DatabaseResult))
{
//get the row
$DatabaseRow = mysql_fetch_object($DatabaseResult);
//put results into array
$Item["ID"] = $Item_ID;
$Item["Name"] = $DatabaseRow->Name;
$Item["FirstName"] = $DatabaseRow->FirstName;# Added
$Item["LastName"] = $DatabaseRow->LastName;# Added
$Item["Title"] = $DatabaseRow->Title;# Added
$Item["ReleaseDate"] = $DatabaseRow->ReleaseDate;# Added
3 In /modules/screens these 3
A. item
B. add_item
C. admin_item
A. item. This screen is displaying the product with Skus and picture, I
plainly wanted
to se if I could have it working, so there is no deisgn. But it works...
And that is
all I prensently ask :-))
if(isset($Item["ID"]))
{
/*
** Output the item name and description.
*/
print("<H3>". prepareText($Item["Name"]) . "</H3>\n");
print("<H3>". ($Item["Title"]) . "</H3>\n"); #New
print("<H3>". ($Item["ReleaseDate"]) . "</H3>\n"); #New
if($Item["Graphic"] != "")
And than we have som code regarding pictures, and then:
print($Item["Title"] . "<br>\n"); #New
print($Item["FirstName"] . "<br>\n");#New
print($Item["LastName"] . "<br>\n");#New
print($Item["Description"]);
print("<BR CLEAR=\"ALL\"><BR>\n");
And than I have output of new fields!
But first I need to put data into the database
B. Add_item
Notice the odd L_ADDITEM_NAME in first part of code? That is L_ for
language. Also
this expose me as lazy.. Cause I just added norwegian words to my new
fields. Shuld
have put it in Language file I guess. Cause L_ADDITEM_NAME makes to
software get the
proper title in selected language file and outputs normal words. But it
works anyway.
I just copy and past first block and changed field name.
/* Start the form, and the table that will be used to organize
everything. */
print(StartForm("admin_departments", 'post', 'ADD_ITEM', FALSE,
array("department"=>$department)));
print("<TABLE>\n");
/* Output all of the html form entities. */
print("<TR><TD>" . L_ADDITEM_NAME . "</TD>\n");
print("<TD><INPUT TYPE=\"text\" NAME=\"inputName\" SIZE=\"32\" " .
"VALUE=\"");
print( isset($inputName) ? prepareText($inputName) : "" );
print("\"></TD></TR>\n");
print("<TR><TD>" . Fornavn . "</TD>\n");
print("<TD><INPUT TYPE=\"text\" NAME=\"inputFirstName\" SIZE=\"32\" " .
"VALUE=\"");
print( isset($inputFirstName) ? prepareText($inputFirstName) : "" );
print("\"></TD></TR>\n");
print("<TR><TD>" . Etternavn . "</TD>\n");
print("<TD><INPUT TYPE=\"text\" NAME=\"inputLastName\" SIZE=\"32\" " .
"VALUE=\"");
print( isset($inputLastName) ? prepareText($inputLastName) : "" );
print("\"></TD></TR>\n");
print("<TR><TD>" . Tittel . "</TD>\n");
print("<TD><INPUT TYPE=\"text\" NAME=\"inputTitle\" SIZE=\"32\" " .
"VALUE=\"");
print( isset($inputTitle) ? prepareText($inputTitle) : "" );
print("\"></TD></TR>\n");
print("<TR><TD>" . Releasedato . "</TD>\n");
print("<TD><INPUT TYPE=\"text\" NAME=\"inputReleaseDate\" SIZE=\"32\" "
.
"VALUE=\"");
print( isset($inputReleaseDate) ? prepareText($inputReleaseDate) : "" );
print("\"></TD></TR>\n");
C. admin_item
OK. so now I can go to admin and add a new record. But I also want a
chance to modefy
it.
/*
** Get the main information for this item.
*/
if ($continueScript) # get it into start of SELECT statment
{
$item = intval($item);
$Query = "SELECT Name, FirstName, LastName, Title, ReleaseDate,
Description, " .
"Keywords,Thumbnail, Graphic, LargeGraphic, DisplayPrecedence, Active
";
and also a litle bit further down
else
{
$itemName = $DatabaseRow[0];
$itemFirstName = $DatabaseRow[1]; #new
$itemLastName = $DatabaseRow[2]; #new
$itemTitle = $DatabaseRow[3]; #new
$itemReleaseDate = $DatabaseRow[4]; #new
Just remember to change the numbers in [ ]
Good luck!!
Bjarne Hansen
--
Christie Walker
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Site: http://www.working-dogs.com/freetrade/
Problems?: [EMAIL PROTECTED]