MySQL Forums
Forum List  »  PHP

Getting php code to reflect addition of fields in mySQL
Posted by: Kim
Date: January 17, 2006 02:11PM

I'm working with existing php code that calls to a mySQL database...code someone else wrote. The database holds pictures and descriptions of merchandise for sale.

I had to add more image fields to the existing mySQL database. The customer makes additions and changes to the database using an admin.php file instead of going into the mySQL database, as it is more user friendly for them. I'm having trouble with the admin.php file recognizing those additional fields I created in the mySQL database.

Any help will be greatly appreciated!!!

Here is a snippet of the code I'm working with.

// The query here gets the information for the record in the database
// which will be modified. We only modify one record at a time.

//here we get the qid from the passed variable
if($_GET[$config_primary_key] != '') { $config_primary_key_value = $_GET[$config_primary_key]; }
elseif($_POST[$config_primary_key] != '') { $config_primary_key_value = $_POST[$config_primary_key]; }
else { FormMin_script_error(6, "No config_primary_key Specified"); }


$FormMin_query = "SELECT * FROM ".$final_data[0][0]." WHERE ".$config_primary_key." = ".$config_primary_key_value;
$FormMin_result = execute_query($FormMin_query,$FormMin_connection);
$num_results = mysql_num_rows($FormMin_result);

$FormMin_row = mysql_fetch_array($FormMin_result);

for($j=1; $j<$item_counter; $j++) {


// Here we format the row to match the setting in section 1

if($side_or_top == 'side') {
$row_string = " <tr><td align=\"left\"><span class=\"RowTitle\">".$final_data[$j][2]."</span></td><td valign=\"".$final_data[0][6]."\" align=\"".$final_data[$j][5]."\">";
}
elseif ($side_or_top == 'top') {
$row_string = " <tr><td width=\"100%\" align=\"left\"><span class=\"RowTitle\">".$final_data[$j][2]."</span></td></tr>\n";
$row_string .= " <tr><td width=\"100%\" valign=\"".$final_data[0][6]."\" align=\"".$final_data[$j][5]."\">";
}
else { FormMin_script_error(4, "Invalid Declaration of config side_or_top"); }

// This switch handles the display of the different types of data

switch($final_data[$j][0]) {

case "file" :


// remove the unique id from the name of the file so we don't confuse people
$image_striped_name = ereg_replace("^[0-9]+_", "", $FormMin_row[$final_data[$j][1]]);

// For a file (image), we need to open up that file and make sure we display it using the config thumb value
$row_string .= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";


//create opening input
$row_string .= "<tr><td><input ";

if($final_data[$j][0] != '') { $row_string .= "type=\"".$final_data[$j][0]."\" "; }
else { FormMin_script_error(2, "Input Type of Line $j+1"); }


//name needs to be files[] to work with image uploads
if($final_data[$j][0] == 'file') {
if($final_data[$j][1] != '') { $row_string .= "name=\"upload_files[]\" "; }
else { FormMin_script_error(2, "Input Name of Line $j+1"); }
}
else {
if($final_data[$j][1] != '') { $row_string .= "name=\"".$final_data[$j][1]."\" "; }
else { FormMin_script_error(2, "Input Name of Line $j+1"); }
}

if($final_data[$j][3] != '') { $row_string .= "size=\"".$final_data[$j][3]."\" "; }
else { FormMin_script_error(2, "Input Width of Line $j+1"); }

if(($final_data[$j][6] != '') || ($final_data[$j][7] != "0")) { $row_string .= "maxlength=\"".$final_data[$i][7]."\" "; }
else { FormMin_script_error(2, "Input Maxlength of Line $j+1"); }

//create end cap for input
$row_string .= ">&nbsp;&nbsp;&nbsp;<BR><span class=\"RowText\">Leave Blank To Keep Current Image</span></td>";

Options: ReplyQuote


Subject
Written By
Posted
Getting php code to reflect addition of fields in mySQL
Kim
January 17, 2006 02:11PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.