Jump to content

Trying to get multiple image paths to upload to a mysql database


mdmartiny

Recommended Posts

I am in the process of writing a CMS for a friend that is looking to add a classified section to his site. He will be the only one that will ever use it.

 

I got the code to work with one image when he asked me if I could do it so he could post 6 images for each item. I am unable to figure out how to do this. I was told to do this with a while loop.

 

This is the code that I have written so far.

<?php

//Check to make sure title is filled in. If not redirects to show_add.php
if (!$_POST[title]) {
header("Location: show_add.php");
exit;
} else {
//check and see if a session has started
session_start();
}
//if session has not been properly started redirects back to the administration menu
if ($_SESSION[valid] != "yes") {
header("Location: admin_menu.php");
exit;
}

include('includes/connection.php');


//check and see if the type of uploaded file is an image
function is_valid_type($file) {
$valid_types = array("image/jpg", "image/jpeg", "image/gif", "image/bmp");

if (in_array($file['type'], $valid_types))
	return 1;
return 0;
}

//Set Constants
$TARGET_PATH = "/home/content/m/i/k/mikedmartiny/html/db_images/";

$title = $_POST['title'];
$year = $_POST['year'];
$make = $_POST['make'];
$model = $_POST['model'];
$descript = $_POST['descript'];
$image = $_FILES['image'];

//Sanitize the inputs
$title = mysql_real_escape_string($title);
$year = mysql_real_escape_string($year);
$make = mysql_real_escape_string($make);
$model = mysql_real_escape_string($model);
$descript = mysql_real_escape_string($descript);
$image['name'] = mysql_real_escape_string($image['name']);

//$target_path full string
$TARGET_PATH .= $image['name'];

//make sure that all fields from form are filled in
if ( $title == "" || $year == "" || $make =="" || $model == "" || $descript == "" || $image['name'] == "") {
$_SESSION['error']  = "ALL FIELDS ARE REQUIRED!";
header ("Location: show_add.php");
exit;
}

//check to make sure it has the right file type
if (!is_valid_type($image)){
$_SESSION['error'] = "You must upload a jpeg, gif, or bmp";
header ("Location: show_add.php");
exit;
}

//check to see if a file with that name exsists
if (file_exists($TARGET_PATH)){
$_SESSION['error'] = "A FILE WITH THAT NAME ALL READY EXIST!";
header ("Location: show_add.php");
exit;
}

//move the image - write path to database
while($image <=2) {
move_uploaded_file($image['tmp_name'], $TARGET_PATH)
} else {
// Make sure you chmod the directory to be writeable
$_SESSION['error'] = "COULD NOT UPLOAD FILE. CHECK WRITE/REWRITE PERMISSIONS ON THE FILE DIRECTORY!";
header ("Location: show_add.php");
exit;
}

$sql = "INSERT INTO $table (id, title, year, make, model, descript, image, image_two) VALUES ('', '$_POST[title]', '$_POST[year]', '$_POST[make]', '$_POST[model]', '$_POST[descript]', '" . $image['name'] . "', '" . $image['name'] . "')";

$result = mysql_query($sql) or die ("Could not insert data into DB: " . mysql_error());

?>

 

I only have it set up to work with 2 images right now. I thought it would be easier to get it to work properly. Then I could just add in the rest of the info later.

 

Any help would be greatly appreciated.

Link to comment
Share on other sites

here it is

 

<?php

//Check to make sure title is filled in. If not redirects to show_add.php
if (!$_POST[title]) {
header("Location: show_add.php");
exit;
} else {
//check and see if a session has started
session_start();
}
//if session has not been properly started redirects back to the administration menu
if ($_SESSION[valid] != "yes") {
header("Location: admin_menu.php");
exit;
}

include('includes/connection.php');


//check and see if the type of uploaded file is an image
function is_valid_type($file) {
$valid_types = array("image/jpg", "image/jpeg", "image/gif", "image/bmp");

if (in_array($file['type'], $valid_types))
	return 1;
return 0;
}

//Set Constants
$TARGET_PATH = "/home/content/m/i/k/mikedmartiny/html/db_images/";

$title = $_POST['title'];
$year = $_POST['year'];
$make = $_POST['make'];
$model = $_POST['model'];
$descript = $_POST['descript'];
$image = $_FILES['image'];

//Sanitize the inputs
$title = mysql_real_escape_string($title);
$year = mysql_real_escape_string($year);
$make = mysql_real_escape_string($make);
$model = mysql_real_escape_string($model);
$descript = mysql_real_escape_string($descript);

//$target_path full string
$TARGET_PATH .= $image['name'];

//make sure that all fields from form are filled in
if ( $title == "" || $year == "" || $make =="" || $model == "" || $descript == "" || $image['name'] == "") {
$_SESSION['error']  = "ALL FIELDS ARE REQUIRED!";
header ("Location: show_add.php");
exit;
}

//check to make sure it has the right file type
if (!is_valid_type($image)){
$_SESSION['error'] = "You must upload a jpeg, gif, or bmp";
header ("Location: show_add.php");
exit;
}

//check to see if a file with that name exsists
if (file_exists($TARGET_PATH)){
$_SESSION['error'] = "A FILE WITH THAT NAME ALL READY EXIST!";
header ("Location: show_add.php");
exit;
}

//move the image - write path to database
while(list($key,$value) = each($_FILES[image][name])) {
if (!empty($value)) {
	$filename = $value;
	$filename = str_replace(" ","_",$filename);
	$add = $TARGET_PATH;
	copy($_FILES[images][tmp_name][$key], $add);
}
} 

$sql = "INSERT INTO $table (id, title, year, make, model, descript, image, image_two) VALUES ('', '$_POST[title]', '$_POST[year]', '$_POST[make]', '$_POST[model]', '$_POST[descript]', '" . $image['name'] . "', '" . $image['name'] . "')";

$result = mysql_query($sql) or die ("Could not insert data into DB: " . mysql_error());

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Classified Added</title>
</head>
<body>
<div>
   <h3>The following information has been added to the <?php echo "$table"; ?></h3>
   <p> <strong>Title:</strong> <?php echo "$title"; ?> </p>
   <p> <strong>Year:</strong> <?php echo "$year"; ?> </p>
   <p> <strong>Make:</strong> <?php echo "$make"; ?> </p>
   <p> <strong>Model:</strong> <?php echo "$model"; ?> </p>
   <p> <strong>Description:</strong> <?php echo "$descript"; ?> </p>
   <p> <strong>Image:</strong> <?php echo "<img src=\"../db_images/" . $image['name'] . "\">"; ?></p>
   <p><a href="show_add.php">Add another classified ad</a></p>
   <p><a href="admin_menu.php">Return to main menu</a></p>
</div>
</body>
</html>

Link to comment
Share on other sites

here is the form

 

<?php

//session start
session_start();

if (isset($_SESSION['error'])){
echo "<span id=\"error\"><p>" . $_SESSION['error'] . "</p></span>";
unset($_SESSION['error']);
}

$max_no_img = 6;

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add Classified Ad</title>
</head>
<body>
<h1>Add Classified Ad</h1>
<h2><em>Add a Ad</em></h2>

<?php
echo "<form method=\"POST\" action=\"add_ad.php\" enctype=\"multipart/form-data\">
   <p> <strong>Title:</strong>
      <input type=\"text\" name=\"title\" id=\"title\" length=\"25\" maxlength=\"25\" />
   </p>
   <p> <strong>Year:</strong>
      <input type=\"text\" name=\"year\" id=\"year\" length=\"25\" maxlength=\"25\" />
   </p>
   <p> <strong>Make</strong>
      <input type=\"text\" name=\"make\" id=\"make\" length=\"25\" maxlength=\"25\" />
   </p>
   <p> <strong>Model:</strong>
      <input type=\"text\" name=\"model\" id=\"model\" length=\"25\" maxlength=\"25\" />
   </p>
   <p> <strong>Description:</strong>
      <textarea name=\"descript\" id=\"descript\" rows=\"5\" cols=\"75\"></textarea>
   </p>";
   for ($i = 1; $i <= $max_no_img; $i++){
echo "<p><strong>Image $i</strong><br />
   <input type=\"file\" name=\"image[]\" id=\"image[]\" />
</p>";
   }
   ?>
   <p><input type="submit" name="submit" id="name" value="Add Ad" /></p>
</form>
   <p><a href="admin_menu.php">Return to Administration Menu</a></p>
   
</body>
</html>

Link to comment
Share on other sites

Ok rough idea minimally tested (took some liberties with your formatting)...

The form:

<?php
//session start
session_start();
$max_no_img = 6;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add Classified Ad</title>
</head>
<body>
<h1>Add Classified Ad</h1>
<h2><em>Add a Ad</em></h2>
<form method="POST" action="process.php" enctype="multipart/form-data">
   <p><strong>Title:</strong><input type="text" name="title" id="title" length="25" maxlength="25" /></p>
   <p><strong>Year:</strong><input type="text" name="year" id="year" length="25" maxlength="25" /></p>
   <p><strong>Make</strong><input type="text" name="make" id="make" length="25" maxlength="25" /></p>
   <p><strong>Model:</strong><input type="text" name="model" id="model" length="25" maxlength="25" /></p>
   <p><strong>Description:</strong><textarea name="descript" id="descript" rows="5" cols="75"></textarea></p>
<input type="hidden" name="max_no_img" value="<?PHP echo $max_no_img; ?>">
<?PHP
for ($i = 1; $i <= $max_no_img; $i++){
	?>
	<p><strong>Image <?PHP echo $i; ?></strong><br />
   <input type="file" name="images[]" id="images[]" /></p>
	<?PHP
   }
   ?>
   <p><input type="submit" name="submit" id="name" value="Add Ad" /></p>
</form>
   <p><a href="admin_menu.php">Return to Administration Menu</a></p>
</body>
</html>

process.php

<?PHP
session_start();

/* 
begin notes 
1.	no messages have been done for errors
2.	cleansing of data needs to be increased
3.	rather than error, if image name exists a new name is created using datetime and orig name
4.	names are cleansed so as to only contain alphanumeric and decimal
5.	all of the image names uploaded are contained in the variable $all_images.
	the names are separated by commas
end notes
*/
$title = $_POST['title'];
$year = $_POST['year'];
$make = $_POST['make'];
$model = $_POST['model'];
$descript = $_POST['descript'];
$max_files = $_POST['max_no_img'};
$valid_types = array ("image/gif", "image/jpg", "image/jpeg", "image/bmp");
$max_size = 2000000;
$path = "";
$i=0;
while($i<$max_files) {
if ($_FILES['images']['name'][$i] != '') { /* check if file name field empty or not */
	if (in_array($_FILES['images']['type'][$i], $valid_types)) { /* check for valid image type */
		if($_FILES['images']['size'][$i]<=$max_size) { /* check for allowed size */
			$check_name = $_FILES['images']['name'][$i];
			$check_name = preg_replace("/[^a-zA-Z0-9\.]/", "", $check_name);
			$good = 0;
			while($good==0) {
				if(!file_exists($path . $check_name)) { /* check file that file name already exists */
					/* move the file */
					if (copy($_FILES['images']['tmp_name'][$i], $check_name)) {
					$all_images = $all_images . $check_name . ",";
						$good=1;
					}else{
						/* unable to move file */
					}
				}else{ /* create new name */
					$check_name = date("YmdHis") . $_FILES['images']['name'][$i];
					$check_name = preg_replace("/[^a-zA-Z0-9\.]/", "", $check_name);
				}
			}
		}else{
			/* bad size trap */
		}
	}else{
		/* bad type trap */
	}
}else{
	/* empty file trap */
}
$i ++;
}
/* store the data to your db here */
/* display message here */
?>

Link to comment
Share on other sites

I changed my code and added to it. Now the code is not working at all.

 

It is not putting the files in the folder on my server. When it writes to the database it creates a new record but nothing is inside of that record all of the fields are blank.

 

What am I doing wrong?

 

Here is how my code looks now

<?PHP
session_start();

require('includes/connection.php');

$title = $_POST['title'];
$year = $_POST['year'];
$make = $_POST['make'];
$model = $_POST['model'];
$descript = $_POST['descript'];
$max_files = $_POST['max_no_img'];
$valid_types = array ("image/gif", "image/jpg", "image/jpeg", "image/bmp");
$max_size = 2000000;
$path = "/home/content/m/i/k/mikedmartiny/html/db_images";
$i=0;

while($i<$max_files) {
if ($_FILES['images']['name'][$i] != '') { /* check if file name field empty or not */
if (in_array($_FILES['images']['type'][$i], $valid_types)) { /* check for valid image type */
	if($_FILES['images']['size'][$i]<=$max_size) { /* check for allowed size */
		$check_name = $_FILES['images']['name'][$i];
		$check_name = preg_replace("/[^a-zA-Z0-9\.]/", "", $check_name);
		$good = 0;
		while($good==0) {
			if(!file_exists($path . $check_name)) { /* check file that file name already exists *
			   /* move the file */
			   if (copy($_FILES['images']['tmp_name'][$i], $check_name)) {
				   $all_images = $all_images . $check_name . ",";
					  $good=1;
				   }else{
					   die ("CHECK WRITE PERMISSIONS OF IMAGE FOLDER!");
					   }
				}else{ /* create new name */
					$check_name = date("YmdHis") . $_FILES['images']['name'][$i];
					$check_name = preg_replace("/[^a-zA-Z0-9\.]/", "", $check_name);
				}
			}
	}else{
		die ("FILE SIZE IS TO LARGE. REZIZE IMAGE!");
		}
}else{
	die("INVALID IMAGE FORMAT. IMAGES MUST BE .JPG, .GIF, .BMP OR .PNG!");
}
}else{
die("ALL FIELDS ARE REQUIRED!");
}
$i ++;
}

$sql = "INSERT INTO $table (id, title, year, make, model, descript, image, image_two) VALUES ('', '$_POST[title]', '$_POST[year]', '$_POST[make]', '$_POST[model]', '$_POST[descript]', '" . $images['name'] . "', '" . $images['name'] . "')";

$result = mysql_query($sql) or die ("Could not insert data into DB: " . mysql_error());

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Classified Added</title>
</head>
<body>
<div>
   <h3>The following information has been added to the <?php echo "$table"; ?></h3>
   <p> <strong>Title:</strong> <?php echo "$title"; ?> </p>
   <p> <strong>Year:</strong> <?php echo "$year"; ?> </p>
   <p> <strong>Make:</strong> <?php echo "$make"; ?> </p>
   <p> <strong>Model:</strong> <?php echo "$model"; ?> </p>
   <p> <strong>Description:</strong> <?php echo "$descript"; ?> </p>
   <p> <strong>Image 1:</strong> <?php echo "<img src=\"../db_images/" . $image['name'] . "\">"; ?></p>
   <p> <strong>Image 2: </strong> <?php echo "<img src=\"../db_images/" . $image['name'] . "\">"; ?></p>
   <p><a href="show_add.php">Add another classified ad</a></p>
   <p><a href="admin_menu.php">Return to main menu</a></p>
</div>
</body>
</html>

 

One more things can I put HTML code on die messages? I would like to add like a return to previous page button or something like that so they do not have to hot the back button.

 

Thank you for all of your help with this

Link to comment
Share on other sites

Ok, answering in reverse...

 

1. You haven't defined the value of $table

2. change this

$sql = "INSERT INTO $table (id, title, year, make, model, descript, image, image_two) VALUES ('', '$_POST[title]', '$_POST[year]', '$_POST[make]', '$_POST[model]', '$_POST[descript]', '" . $images['name'] . "', '" . $images['name'] . "')";

to this

$sql = "INSERT INTO $table (title, year, make, model, descript, image, image_two) VALUES ('$title', '$year', '$make', '$model', '$descript', '$all_images')";

remember $all_images has all the uploaded names

 

Now, as to files not being uploaded.

manually ftp an image into the folder where you are planning on storing the images.

 

then write this short file and save it in the folder where your form and process script reside. then run the test script

test.php

<?PHP
$path = "/home/content/m/i/k/mikedmartiny/html/db_images";
$file = /* PUT THE NAME OF THE IMAGE YOU MANUALLY UPLOADED HERE */
?>
<img src = "<?PHP echo $path ."/" . $file; ?>">
<?PHP
?>

Link to comment
Share on other sites

Your path statement may be wrong - presuming your scripts are in the home folder

change this

<?PHP
$path = "/home/content/m/i/k/mikedmartiny/html/db_images";
$file = /* PUT THE NAME OF THE IMAGE YOU MANUALLY UPLOADED HERE */
?>
<img src = "<?PHP echo $path ."/" . $file; ?>">
<?PHP
?>

to this

<?PHP
$path = "content/m/i/k/mikedmartiny/html/db_images";
$file = /* PUT THE NAME OF THE IMAGE YOU MANUALLY UPLOADED HERE */
?>
<img src = "<?PHP echo $path ."/" . $file; ?>">
<?PHP
?>

Link to comment
Share on other sites

I still get the same thing..... they are all in a folder called CMS. All the files are in one folder except for the include files and images.

 

The layout looks like

  CMS

      include

      all of my files

 

    the db_images folder is in the root folder of the system

 

I changed

<img src = "<?PHP echo $path ."/" . $file; ?>">

 

to

 

<img src = "<?PHP echo $path ."../" . $file; ?>">

 

to see if that would work and it did not

Link to comment
Share on other sites

 

I still get the same thing..... they are all in a folder called CMS. All the files are in one folder except for the include files and images.

 

The layout looks like

  CMS

      include

      all of my files

 

    the db_images folder is in the root folder of the system

 

I changed

<img src = "<?PHP echo $path ."/" . $file; ?>">

 

to

 

<img src = "<?PHP echo $path ."../" . $file; ?>">

 

to see if that would work and it did not

 

I probably should of mentioned this earlier... when I was only doing one image. It uploaded fine to the directory it has only started since I been trying to make it more than one

Link to comment
Share on other sites

Ok presuming the db_images folder is in the root directory AND presuming you have an image in that folder, try this

 

<?PHP
$image_name = "Insert the name of any image in the db_images folder - DO NOT include the path or slashes";

$path1 =  $_SERVER['DOCUMENT_ROOT'] ."/";
$path2 = $path1 . "db_images/";
$path3 = $path2 . $image_name;
?>
<IMG src="<?PHP $path3; ?>">
<?PHP
?>

Link to comment
Share on other sites

ok, I THINK this will do the trick...

<?PHP
session_start();
require('includes/connection.php');
$title = $_POST['title'];
$year = $_POST['year'];
$make = $_POST['make'];
$model = $_POST['model'];
$descript = $_POST['descript'];
$max_files = $_POST['max_no_img'];
$valid_types = array ("image/gif", "image/jpg", "image/jpeg", "image/bmp",  "image/png");
$max_size = 2000000;
$path = "../db_images/";
$i=0;

while($i<$max_files) {
if ($_FILES['images']['name'][$i] != '') { /* check if file name field empty or not */
	if (in_array($_FILES['images']['type'][$i], $valid_types)) { /* check for valid image type */
		if($_FILES['images']['size'][$i]<=$max_size) { /* check for allowed size */
			$check_name = $_FILES['images']['name'][$i];
			$check_name = preg_replace("/[^a-zA-Z0-9\.]/", "", $check_name);
			$good = 0;
			while($good==0) {
				if(!file_exists($path . $check_name)) { /* check file that file name already exists *
					/* move the file */
					if (copy($_FILES['images']['tmp_name'][$i], $check_name)) {
						$all_images = $all_images . $check_name . ",";
						$good=1;
					}else{
						?>
						CHECK WRITE PERMISSIONS OF IMAGE FOLDER!<br>
						<a href="admin_menu.php">Return to main menu</a>
						<?PHP
						exit();
					}
				}else{ /* create new name */
					$check_name = date("YmdHis") . $_FILES['images']['name'][$i];
					$check_name = preg_replace("/[^a-zA-Z0-9\.]/", "", $check_name);
				}
			}
		}else{
			?>
			FILE SIZE IS TO LARGE. REZIZE IMAGE!<br>
			<a href="admin_menu.php">Return to main menu</a>
			<?PHP
			exit();
		}
	}else{
		?>
		FILE SIZE IS TO LARGE. REZIZE IMAGE!<br>
		<a href="admin_menu.php">Return to main menu</a>
		<?PHP
		exit();
	}
}else{
	/* in the event user uses SOME of the image fields and leaves others blank, we should NOT die on this condition */
}
$i ++;
}
$all_images = rtrim($all_images, ",");

$sql = "INSERT INTO " . $table . " (title, year, make, model, descript, image) VALUES ('$title', '$year', '$make', '$model', '$descript', '$all_images')";
$result = mysql_query($sql) or die ("Could not insert data into DB: " . mysql_error());
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Classified Added</title>
</head>
<body>
<div>
<h3>The following information has been added to the <?php echo "$table"; ?></h3>
<p> <strong>Title:</strong> <?php echo "$title"; ?> </p>
<p> <strong>Year:</strong> <?php echo "$year"; ?> </p>
<p> <strong>Make:</strong> <?php echo "$make"; ?> </p>
<p> <strong>Model:</strong> <?php echo "$model"; ?> </p>
<p> <strong>Description:</strong> <?php echo "$descript"; ?> </p>
<?PHP
if(substr_count($all_images, ',')>0) {
$lines = explode(",", $all_images);
$num_images = count($lines);
}else{
$lines[0] = $all_images;
$num_images = 1;
}
$i=0;
while($i<$num_images) {
?>
	<p><strong>Image <?PHP echo $i +1; ?>:</strong> <img src="<?PHP echo $path . $lines[$i]; ?>"></p>
<?PHP
$i ++;
}
?>
<p><a href="show_add.php">Add another classified ad</a></p>
<p><a href="admin_menu.php">Return to main menu</a></p>
</div>
</body>
</html>

Link to comment
Share on other sites

to retrieve...

 

<?PHP
session_start();
require('includes/connection.php');
$wid = /* the id value of the record you are looking for */
$sql = "SELECT * FROM " . $table . " WHERE is = '$wid'";
$result = mysql_query($sql) or die ("Could not insert data into DB: " . mysql_error());
$num_rows = mysql_num_rows($result);
if($num_rows != 1) {
exit(); /* not found */
}
$row = mysql_fetch_array($result);
echo $row['title'] . "<br>";
echo $row['year'] . "<br>";
echo $row['make'] . "<br>";
echo $row['model'] . "<br>";
echo $row['description'] . "<br>";
$all_images = $row['image'];
if(substr_count($all_images, ',')>0) {
$lines = explode(",", $all_images);
$num_images = count($lines);
}else{
$lines[0] = $all_images;
$num_images = 1;
}
$i=0;
while($i<$num_images) {
?>
<p><strong>Image <?PHP echo $i +1; ?>:</strong> <img src="<?PHP echo $path . $lines[$i]; ?>"></p>
<?PHP
$i ++;
}
?>

Link to comment
Share on other sites

I am sorry for being a terrible pain in your butt. I have never had this much trouble with getting a script to work but then again I have never tried to get more than one image to work. I appreciate all of the help that you are giving me and all of the patience that you are showing me.

 

I am confused about the $wid. What should I put there?

Link to comment
Share on other sites

At some point you or your user will want to see the information about a specific record - perhaps it might be a drop down list of different models. In your drop down list you would be making the value each selection the id of the particular record...

example:

<select name="wid">
<option value="22">1927 Ford Sedan</option>
<option value="67">2011 Chevrolet Corvette</option>
</select>

when you process that particular form you would

<?PHP
$wid = $_POST['wid']

You would then use that value to get that particular record where id = '$wid'

 

make sense?

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.