I want to keep my project number unique. So how would I say (in PHP) that script should do insert if project number is unique, but should print out a message if not, and where abouts in the script would I put it?
Georgina
<html> <head> <title>Project Database - Project Details</title> </head> <body bgcolor="#9966FF" link="lime" vlink="yellow"> <div align="center"><img src="compSciPageBanner.gif"/></div> <?php if ($submit == "Click here to enter project") { // The submit button was clicked! // Get the input and store it in the database. //make a connection to the database PutEnv("ORACLE_HOME=/usr/local/applic/oracle/816"); $connection = OCILogon("geb97","f8s0g99","trdb"); //if a connection to the database is not made output a message if (!$connection) { echo "I couldn't make a connection!"; exit; } //formulate the query $query = "select projectID, moduleID, title, originator, softwareHardware, specialSkills, status, externalAgreement, background, tasks, steps, references from PROJECT WHERE projectID='$projectID'"; //insert values into the table $insert = "insert into PROJECT values ('$projectID', '$moduleID', '$title', '$originator', '$softwareHardware', '$specialSkills', '$status', '$externalAgreement', '$background', '$tasks', '$steps', '$references')"; //parse the two statements $qry_statement = OCIParse ($connection, $query); $ins_statement = OCIParse ($connection, $insert); //execute the insert statement and print error message if there is an error $result = OCIExecute($ins_statement); if (!$result) { echo OCIError($ins_statement)."<p>"; exit; } //execute the query statement OCIExecute($qry_statement); //retrieve the results of the query statement and present them in the following way while (ocifetch($qry_statement)) { //line to tell the user the project has been entered into the database echo "<p><div align=\"center\">The following project has been entered into the Project Database: -</div></p>"; //display the project title echo "<h1 align=\"center\">". OCIresult($qry_statement,'TITLE') ."</h1>"; //display the project number echo "<p><big><b>Project Number: </b></big>". OCIresult($qry_statement, 'PROJECTID')."</p>"; //display the originator echo "<p><big><b>Principal Originator: </b></big>". OCIresult($qry_statement, 'ORIGINATOR') ."</p>"; // no supervisor will be shown because these are not added at the time and a project can have many supervisors //display the software/hardware requirements echo "<p><big><b>Software/Hardware Requirements: </b></big>". OCIresult($qry_statement, 'SOFTWAREHARDWARE') ."</p>"; //display the special skills needed to be used echo "<p><big><b>Special Skills: </b></big>". OCIresult($qry_statement, 'SPECIALSKILLS') ."</p>"; //display which module the project is suitable for echo "<p><big><b>Suitability: </b></big>". OCIresult($qry_statement, 'MODULEID') ."</p>"; //display the status echo "<p><big><b>Status: </b></big>". OCIresult($qry_statement, 'STATUS') ."</p>"; //line to break up text echo "<hr/>"; //a heading for the new section echo "<h2>Description</h2>"; //display the project background echo "<p><big><b>Background: </b></big>"; echo "<p>" . OCIresult($qry_statement, 'BACKGROUND') ."</p>"; //display the project task/s echo "<p><big><b>Project Task/s: </b></big>"; echo "<p>" . OCIresult($qry_statement, 'TASKS'). "</p>"; //display the specific steps echo "<p><big><b>Specific Steps: </b></big>"; echo "<p>" . OCIresult($qry_statement, 'STEPS'). "</p>"; //display the references echo "<p><big><b>References: </b></big>"; echo "<p>" . OCIresult($qry_statement, 'REFERENCES'). "</p>"; //a line to break up the text echo "<hr/>"; //contact email address - couldn't make this into a link because too difficult echo "<p><div align=\"center\"><i>For further information please contact: </i>" . OCIresult($qry_statement, 'ORIGINATOR')."@aber.ac.uk </div></p>"; //a final line echo "<hr/>"; //the 1st link allows you to register an interest in the project, the 2nd allows you to withdraw the project echo "<p><div align=\"center\"><a href = \"construction.html\"> <img src = \"registerWithProject.jpg\" border = \"0\"/></a> <a href = \"construction.html\"><img src = \"removeProject.jpg\" border = \"0\"/></a></div></p>"; }//end of while statement //log off the database OCILogoff ($connection); }//end of if statement ?> <! two buttons allow the user to enter another project or email a supervisor> <p><div align="center"><a href = "enterProject1.html"><img src = "anotherProject.jpg" border = "0"/></a> <a href = "construction.html"><img src = "emailSupervisor.jpg" border = "0"/></a></div></p> <div align="center"> <pre> <a href = "http://www.aber.ac.uk">Return to UWA Home Page</a> </div> <div align="center"> <pre> <a href = "http://www.aber.ac.uk/compsci">Return to Computer Science Home Page</a> </pre></div> <div align="center"> <pre> <a href = "mainMenu1.html">Return to Project Database Main Menu</a> </pre></div> </body> </html>
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]