Jump to content

Multiple submit buttons for single table


librarian

Recommended Posts

OK. I'm writing an application that will have 16 images on a web page.  When you click the image it will add an entry to the table in mysql database.  This works fine with ONE field.  I am stumped on how to add the other 15 fields.  So how would I add a fields called phonedirectional, emaildirectional, etc  I am sure it is some kind of if else statement but I cannot get the syntax right. 

 

 

 

<?php

$con = mysql_connect("","");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

mysql_select_db("reference", $con);

 

// Insert a row of information into the table "info"

 

mysql_query("INSERT INTO info

(INPERSONDIRECTIONAL) VALUES('1')")

or die(mysql_error());

 

 

$Time= date("m/d/y,time()");

 

//$Time = date("F j, Y, g:i a");

 

//$sql="INSERT INTO info (INPERSONDIRECTIONAL)

//VALUES

//('$_POST[iNPERSONDIRECTIONAL]','$_POST[Time]')";

 

//if (!mysql_query($sql,$con))

  {

  //die('Error: ' . mysql_error());

  }

echo "1 record added";

 

 

 

mysql_close($con)

 

 

 

 

?>

 

AND the HTML if that helps...

 

 

!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=iso-8859-1" />

<title>Test</title>

<style type="text/css">

<!--

.style2 {

font-size: x-large;

font-weight: bold;

color: #000000;

}

body {

background-color: #66CCFF;

}

-->

</style>

</head>

<body>

<h2>

<div align="center">

  <h3><span class="style2">Ref Stats Collection

    </h1>

    </span><br> 

  </h3>

</div>

<form method="post" action="process.php" >

<table width="657" height="69" border="0">

        <tr>

          <td width="127"><input name="INPERSONDIRECTIONAL" type="image" value="1" src="CosmicGelDa8.gif" align="middle" width="123" height="40 /><br>

<form method="post="post"" action="process.php" /></td>

          <td width="127"><input name="INPERSONDIRECTIONAL" type="image" value="1" src="CosmicGelDa8.gif" align="middle" width="123" height="40 /><br>

<form method="post="post"" action="process.php"></td>

          <td width="127"><input name="INPERSONDIRECTIONAL" type="image" value="1" src="CosmicGelDa8.gif" align="middle" width="123" height="40 /><br>

<form method="post="post"" action="process.php"></td>

          <td width="127"><input name="INPERSONDIRECTIONAL" type="image" value="1" src="CosmicGelDa8.gif" align="middle" width="123" height="40 /><br>

<form method="post="post"" action="process.php" /></td>

          <td width="127"><input name="INPERSONDIRECTIONAL" type="image" value="1" src="CosmicGelDa8.gif" align="middle" width="123" height="40 /><br>

<form method="post="post"" action="process.php" /></td>

        </tr>

        <tr>

          <td><input name="phonedirectional" type="image" value="1" src="CosmicGelDa3.gif" align="middle" width="123" height="40 /><br>

<form method="post="post"" action="process.php" /></td>

          <td><input name="phonedirectional" type="image" value="1" src="CosmicGelDa3.gif" align="middle" width="123" height="40 /><br>

<form method="post="post"" action="process.php" /></td>

          <td><input name="phonedirectional" type="image" value="1" src="CosmicGelDa3.gif" align="middle" width="123" height="40 /><br>

<form method="post="post"" action="process.php" /></td>

          <td><input name="phonedirectional" type="image" value="1" src="CosmicGelDa3.gif" align="middle" width="123" height="40 /><br>

<form method="post="post"" action="process.php" /></td>

          <td><input name="phonedirectional" type="image" value="" src="CosmicGelDa3.gif" align="middle" width="123" height="40 /><br>

<form method="post="post"" action="process.php" /></td>

        </tr>

      </table>

 

<table width="657" height="59" border="0">

  <tr>

    <td width="127" height="55"><input name="INPERSONDIRECTIONAL" type="image" value="" src="CosmicGelDa8.gif" align="middle" width="123" height="40 /><br>

<form method="post="post"" action="process.php" /></td>

    <td width="127"><input name="INPERSONDIRECTIONAL" type="image" value="" src="CosmicGelDa8.gif" align="middle" width="123" height="40 /><br>

<form method="post="post"" action="process.php" /></td>

    <td width="127"><input name="INPERSONDIRECTIONAL" type="image" value="" src="CosmicGelDa8.gif" align="middle" width="123" height="40 /><br>

<form method="post="post"" action="process.php" /></td>

    <td width="127"><input name="INPERSONDIRECTIONAL" type="image" value="" src="CosmicGelDa8.gif" align="middle" width="123" height="40 /><br>

<form method="post="post"" action="process.php" /></td>

    <td width="127"><input name="INPERSONDIRECTIONAL" type="image" value="" src="CosmicGelDa8.gif" align="middle" width="123" height="40 /><br>

<form method="post="post"" action="process.php" /></td>

  </tr>

</table>

<table width="657" height="59" border="0">

  <tr>

    <td width="127" height="55"><input name="INPERSONDIRECTIONAL" type="image" value="" src="CosmicGelDa8.gif" align="middle" width="123" height="40 /><br>

<form method="post="post"" action="process.php" /></td>

    <td width="127"><input name="INPERSONDIRECTIONAL" type="image" value="" src="CosmicGelDa8.gif" align="middle" width="123" height="40 /><br>

<form method="post="post"" action="process.php" /></td>

    <td width="127"><input name="INPERSONDIRECTIONAL" type="image" value="" src="CosmicGelDa8.gif" align="middle" width="123" height="40 /><br>

<form method="post="post"" action="process.php" /></td>

    <td width="127"><input name="INPERSONDIRECTIONAL" type="image" value="" src="CosmicGelDa8.gif" align="middle" width="123" height="40 /><br>

<form method="post="post"" action="process.php" /></td>

    <td width="127"><input name="INPERSONDIRECTIONAL" type="image" value="" src="CosmicGelDa8.gif" align="middle" width="123" height="40 /><br>

<form method="post="post"" action="process.php" /></td>

  </tr>

</table>

<table width="1080" height="89" border="0">

  <tr>

    <td width="127"> </td>

    <td width="130"> </td>

    <td width="156"> </td>

    <td width="203"> </td>

    <td width="203"> </td>

    <td width="203"> </td>

  </tr>

</table>

<p> </p>

<p> </p>

<p> </p>

</body>

 

</html>

 

 

{code]
<?php
$con = mysql_connect("","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("reference", $con);

// Insert a row of information into the table "info"

mysql_query("INSERT INTO info
(INPERSONDIRECTIONAL) VALUES('1')")
or die(mysql_error());


$Time= date("m/d/y,time()");

//$Time = date("F j, Y, g:i a");

//$sql="INSERT INTO info (INPERSONDIRECTIONAL)
//VALUES
//('$_POST[iNPERSONDIRECTIONAL]','$_POST[Time]')";

//if (!mysql_query($sql,$con))
  {
  //die('Error: ' . mysql_error());
  }
echo "1 record added";



mysql_close($con)




?> 

Archived

This topic is now archived and is closed to further replies.

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