Jump to content

Edit/ Update Form


pingme81

Recommended Posts

Dear all,

 

I am using Dreamweaver and MySQL to create a web base system.

I am unable to solve the edit form problem.

When I key in a number to search, the on the result display page, I click Edit.

After clicking Edit, it should load the page which is a form with all the details in the fields for me to update.

However, the page is blank.

 

Can anyone of you please kindly help me?

 

Thank you.

 

This is my editform


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>NMRR >> National Medical Research Registration</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->

</script>
</head>
<br><br><br><br><br><br><br><br>
<body>
<div id="Layer1" style="position:absolute; left:3px; top:15px; width:384px; height:100px; z-index:1"><img src="banner.png" width="777" height="104"></div>
<div id="Layer4" style="position:absolute; left:3px; top:120px; width:761px; height:8px; z-index:4"><img src="Hline.JPG" width="776" height="20"></div>
<div id="Layer9" style="position:absolute; left:358px; top:289px; width:0px; height:3px; z-index:9"></div>
<div id="Layer11" style="position:absolute; left:273px; top:316px; width:0px; height:1px; z-index:11">
  <p> </p>
  <p> </p>
  <p> </p>
  <p> </p>
</div>

<?php
echo ('123testing');

		$host="mysql17.000webhost.com"; // Host name
		$username="a6041704_crcnmrr"; // Mysql username
		$password="crc123"; // Mysql password
		$db_name="a6041704_crcnmrr"; // Database name
		$tbl_name="nmrr"; // Table name
	
   		//make the database connection
   		$conn = mysql_connect("$host", "$username", "$password")or die("cannot connect");
   		mysql_select_db("$db_name")or die("cannot select DB");

		if (isset($_GET['Submit']) && $_GET['Submit'] == "Update")
	{
		//SELECT query
 		$sql = "SELECT id, nmrr, nmrr_id, fwd_date_reg, isr, pi, site, dept, std_pro, std_acad_pro, mrec_yr, title, 
		research_type, research_subtype, cp_name, cp_email FROM nmrr WHERE id='{$_GET['id']}'";
    	$result = mysql_query($sql, $conn) or die(mysql_error());
		
	//if the number of row is less than 1, no record in the database
 	if (mysql_num_rows($result) < 1) die("No record with that ID found");
    else
    	{
      		$row=mysql_fetch_row($result);
?>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<div>
<input type="hidden" name= "id"   value="<?php echo $row[0]  ?>">
</div>

<div id="Layer5" style="position:absolute; left:190px; top:161px; width:620px; height:648px; z-index:12">
  <div align="left">
    <p align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong> 
      Please amend to update record.</strong></font></p>
    <table width="90%" height="360" border="0" align="center">
      <tr> 
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">NMRR</font>:</td>
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
          <input name="nmrr_id2" type="text" value="<?php echo $row[1]  ?>" size="30" maxlength="20">
		 </font></td>
      </tr>
      <tr> 
        <td width="31%"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">NMRR 
          ID:</font></td>
        <td width="69%"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
          <input name="nmrr_id" type="text" value="<?php echo $row[2]  ?>" size="30" maxlength="20">
          </font></td>
      </tr>
      <tr> 
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Forwarded 
          Date Registration:</font></td>
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
		
		<?php $fwd_date_reg =explode("-",$row[3]); ?>

     <select name="day" id="select20">
     <option value="">--Day--</option>
 	<?php
 		for ($i = 1; $i < 32; $i++) 
 		{
  			$day = "";
  			if ($i < 10) $day = "0";
  			$day .= $i;
  			echo "<option value='$day'" . ($fwd_date_reg[0] == $day ? "selected='selected'" : "")
				 . ">$day</option>\n";
 		}
 	?>		
          </select>
		  
          <select name="month" id="select21">
            <option value="">--Month--</option>
            <option value="January"<?php echo $fwd_date_reg[1]=="January"?"Selected":'' ?>>January</option>
            <option value="February"<?php echo $fwd_date_reg[1]=="February"?"Selected":'' ?>>February</option>
            <option value="March"<?php echo $fwd_date_reg[1]=="March"?"Selected":'' ?>>March</option>
            <option value="April"<?php echo $fwd_date_reg[1]=="April"?"Selected":'' ?>>April</option>
            <option value="May"<?php echo $fwd_date_reg[1]=="May"?"Selected":'' ?>>May</option>
            <option value="June"<?php echo $fwd_date_reg[1]=="June"?"Selected":'' ?>>June</option>
            <option value="July"<?php echo $fwd_date_reg[1]=="July"?"Selected":'' ?>>July</option>
            <option value="August"<?php echo $fwd_date_reg[1]=="August"?"Selected":'' ?>>August</option>
            <option value="September"<?php echo $fwd_date_reg[1]=="September"?"Selected":'' ?>>September</option>
            <option value="October"<?php echo $fwd_date_reg[1]=="October"?"Selected":'' ?>>October</option>
            <option value="November"<?php echo $fwd_date_reg[1]=="November"?"Selected":'' ?>>November</option>
            <option value="December"<?php echo $fwd_date_reg[1]=="December"?"Selected":'' ?>>December</option>
          </select>
		  
		  	<select name="year" id="select8">
 	<option value="">--Year--</option>
	<?php
   		for ($i = 2008; $i < 2014; $i++)
   		{
      		echo "<option value='$i'" . ($fwd_date_reg[2] == $i ? "selected='selected'" : "") . ">$i</option>\n";
   		}
	?>
  	</select>
	    </font> </td>
      </tr>
      <tr> 
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">ISR:</font></td>
        <td><select name="isr" id="select16">
            <option value="">--Select--</option>
            <option value="Yes"<?php echo $isr[4]=="Yes"?"Selected":'' ?>>Yes</option>
            <option value="No"<?php echo $isr[4]=="No"?"Selected":'' ?>>No</option>
          </select></td>
      </tr>
      <tr> 
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">PI:</font></td>
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
          <textarea name="pi" cols="50" rows="5" value="<?php echo $row[5]  ?>"></textarea>
		  </font></td>
      </tr>
      <tr> 
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Site:</font></td>
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
          <textarea name="site" cols="50" rows="5" value="<?php echo $row[6]  ?>"></textarea>
          </font> </td>
      </tr>
      <tr> 
        <td>Department: </td>
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
          <textarea name="dept" cols="50" value="<?php echo $row[7]  ?>"></textarea>
          </font></td>
      </tr>
      <tr> 
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Is Student 
          Project:</font></td>
        <td><select name="std_pro" id="select26">
            <option value="">--Select--</option>
            <option value="Yes"<?php echo $std_pro[8]=="Yes"?"Selected":'' ?>>Yes</option>
            <option value="No"<?php echo $std_pro[8]=="No"?"Selected":'' ?>>No</option>
          </select></td>
      </tr>
      <tr> 
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Student 
          Academic Project:</font></td>
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
          <select name="std_acad_pro" id="select25">
            <option value="">--Select--</option>
			<option value="Bachelor"<?php echo $std_acad_pro[9]=="Bachelor"?"Selected":'' ?>>Bachelor</option>
            <option value="Masters"<?php echo $std_acad_pro[9]=="Masters"?"Selected":'' ?>>Masters</option>
            <option value="PhD"<?php echo $std_acad_pro[9]=="PhD"?"Selected":'' ?>>PhD</option>
            <option value="Not Applicable"<?php echo $std_acad_pro[9]=="Not Applicable"?"Selected":'' ?>>Not Applicable</option>
          </select>
          </font></td>
      </tr>
      <tr> 
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">MREC Initial 
          Year Approval: </font></td>
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
          <select name="mrec_yr" id="select33">
            <option value="">--Select--</option>
            <option value="2008"<?php echo $mrec_yr[10]=="2008"?"Selected":'' ?>>2008</option>
            <option value="2009"<?php echo $mrec_yr[10]=="2009"?"Selected":'' ?>>2009</option>
            <option value="2010"<?php echo $mrec_yr[10]=="2010"?"Selected":'' ?>>2010</option>
            <option value="2011"<?php echo $mrec_yr[10]=="2011"?"Selected":'' ?>>2011</option>
            <option value="2012"<?php echo $mrec_yr[10]=="2012"?"Selected":'' ?>>2012</option>
            <option value="2013"<?php echo $mrec_yr[10]=="2013"?"Selected":'' ?>>2013</option>
          </select>
          </font></td>
      </tr>
      <tr> 
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Research 
          Title: </font></td>
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
          <textarea name="rTitle" cols="50" rows="5" value="<?php echo $row[11]  ?>"></textarea>
            </font></td>
      </tr>
      <tr> 
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Research 
          Type: </font></td>
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
          <input name="research_type" type="text" value="<?php echo $row[12]  ?>" size="50" maxlength="50">
          </font></td>
      </tr>
      <tr> 
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Research 
          Subtype: </font></td>
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
          <input name="research_subtype" type="text" value="<?php echo $row[13]  ?>" size="50" maxlength="100">
          </font></td>
      </tr>
      <tr> 
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">CP Name 
          : </font></td>
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
          <textarea name="cp_name" value="<?php echo $row[14]  ?>" cols="50" rows="3"></textarea>
          </font></td>
      </tr>
      <tr> 
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">CP Email: 
          </font></td>
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
          <textarea name="cp_email" value="<?php echo $row[15]  ?>" cols="50" rows="3"></textarea>
          </font></td>
      </tr>
      <tr> 
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
          <input type="submit" name="Submit" value=" Update ">
          </font></strong> </font></td>
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
          <strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
          <input type="Reset" name="Submit2" value="   Clear   ">
          </font></strong></font></strong> </font></strong></font></strong> </font></td>
      </tr>
    </table>
	
    <p><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> </font></strong></p>
    <p><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> </font></strong><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
      </font></strong></p>
    <p><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> </font></strong></p>
    <p><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> </font></strong><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
      </font></strong></p>
  </div>
</div>
 
<div id="Layer2" style="position:absolute; left:10px; top:152px; width:140px; height:45px; z-index:33"> 
<div align="right"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">
<?php echo date ('d F Y  ');?><br>
<?php echo date('H:i:s');?><br>

</font></div>
</div>

<div id="Layer3" style="position:absolute; left:17px; top:213px; width:132px; height:140px; z-index:34"> 
  <table width="101%" border="0">
    <tr> 
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><a href="viewall_admin.php">View 
          All</a></strong></font></div></td>
    </tr>
    <tr> 
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><a href="updateform.php">Add 
          New Record</a></strong></font> </div></td>
    </tr>
    <tr> 
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><a href="adminlogin.php">Search</a></strong></font></div></td>
    </tr>
    <tr> 
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><a href="editform.php">Edit</a></strong></font></div></td>
    </tr>
    <tr> 
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><a href="viewall_admin.php">Delete</a></strong></font></div></td>
    </tr>
    <tr> 
      <td> </td>
    </tr>
    <tr> 
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><a href="adminlogin.php"><strong>[Back]</strong></a></font></div></td>
    </tr>
    <tr> 
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><a href="logout.php"><strong>[Logout]</strong></a></font></div></td>
    </tr>
  </table>
</div>

	<?php
 die();
    }
}
//include 'editform_func.php';
?>
</form>
</body>
</html>

This is my editform_func

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>NMRR >> National Medical Research Registration</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php 
	//declare variables
	$nmrr    			= $_POST['nmrr_id2'];
	$nmrr_id 			= $_POST["nmrr_id"];
	$fwd_date_reg		= $_POST['day']. "-". $_POST['month']. "-". $_POST['year'];
	$isr  	 			= $_POST["isr"];
	$pi	     			= $_POST["pi"];
	$site    			= $_POST["site"];
	$dept	 			= $_POST["dept"];
	$std_pro 			= $_POST["std_pro"];
	$std_acad_pro  		= $_POST["std_acad_pro"];
	$mrec_yr	    	= $_POST["mrec_yr"];
	$rTitle		    	= $_POST["rTitle"];
	$research_type  	= $_POST["research_type"];
	$research_subtype	= $_POST["research_subtype"];
	$cp_name		    = $_POST["cp_name"];
	$cp_email	        = $_POST["cp_email"];  

	//check for empty fields, if empty, javascript prompt
	
	
	if ((!$nmrr) || (!$nmrr_id) || (!$fwd_date_reg) || (!$isr) || (!$pi) || (!$site) ||
      	(!$dept) || (!$std_pro) || (!$std_acad_pro) || (!$mrec_yr) || (!$rTitle) || (!$research_type) ||
	  	(!$research_subtype) || (!$cp_name) || (!$cp_email))
		
	{
		?>
	    	<script language ="Javascript">
	   		alert("Please complete all fields!"); 
	   		history.back(-1);
	   		</script>
	    <?
		
	}
	else
	{
	
		$host="mysql17.000webhost.com"; // Host name
		$username="a6041704_crcnmrr"; // Mysql username
		$password="crc123"; // Mysql password
		$db_name="a6041704_crcnmrr"; // Database name
		$tbl_name="nmrr"; // Table name
	
   		//make the database connection
   		$conn = mysql_connect("$host", "$username", "$password")or die("cannot connect");
   		mysql_select_db("$db_name")or die("cannot select DB");
	  	$idGen = mt_rand(100000000,999999999);
		
		
			//declare variable
			$ID = $_GET['ID'];

			if (isset($_POST['id']) && isset($_POST['Submit']) && $_POST['Submit'] == "Update")
	{  
		//concatenate variables
		$fwd_date_reg = $_POST['day']. "-". $_POST['month']. "-". $_POST['year'];
	
		//UPDATE query $
		$sql= 	"UPDATE nmrr SET nmrr='{$_POST['nmrr_id2']}', nmrr_id='{$_POST['nmrr_id']}', 
		   		fwd_date_reg='$fwd_date_reg', isr='{$_POST['isr']}',
		   		pi='{$_POST['pi']}', Site='{$_POST['site']}',
		   		dept='{$_POST['dept']}', std_pro='{$_POST['std_pro']}', std_acad_pro='{$_POST['std_acad_pro']}',
				mrec_yr='{$_POST['mrec_yr']}', title='{$_POST['title']}', research_type='{$_POST['research_type']}',
				research_subtype='{$_POST['research_subtype']}', cp_name='{$_POST['cp_name']}',
				cp_email='{$_POST['cp_email']}' WHERE ID='{$_POST['id']}'";
				
 		mysql_query($sql) or die("Couldn't update " . mysql_error());
 		$result = mysql_query($sql);
      	echo "Thank you! Information updated."; 
}	
	  	    
		//refresh the page or redirect the page
  		echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL=update_success.php">'; 
		exit();
	}
?>
</body>
</html>
Link to comment
Share on other sites

 

After clicking Edit, it should load the page which is a form with all the details in the fields for me to update.

However, the page is blank.

Most likely cause of a blank page is an error. Either turn error reporting on or view your servers error log to see what the error is.

Link to comment
Share on other sites

I am sorry. Which forum section should I post this then?

 

It has already been moved by mac_gyver to the PHP section.

 

Also, it looks like you posted your real database credentials. You need to change those now that they're visible to the public.

 

Side note: you should take a look at the following article about the dangers of using PHP_SELF as the form action:

http://seancoates.com/blogs/xss-woes

Link to comment
Share on other sites

As I said earlier if you are getting a blank page then there is most probably an error. To see what the error is you need to turn error reporting on or check your servers error log.

 

To enable error reporting add these lines at the top of editform_func

<?php
error_reporting(E_ALL);
display_errors(TRUE);
?>

Are any errors displayed?

Edited by Ch0cu3r
Link to comment
Share on other sites

I added this to editform_func.php

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
?>

I got errors like:

Notice: Undefined index: nmrr_id2 in/home..../editform_func.php on line 17

And many more similar errors.

Plus a "Please complete all fields" pop up msg.

Link to comment
Share on other sites

I have tested you code for errors in editform.php and there are non.
 
The problem is when you go to site.com/editform.php nothing is displayed due to this

if (isset($_GET['Submit']) && $_GET['Submit'] == "Update")
{
// rest of page code here
}

It will only display the edit form if your go to editform.php using the following url site.com/editform.php?Submit=Update&id=1 . Where 1 relates to the record's id you're trying to edit in the nmrr table.

 

 

 

When I key in a number to search, the on the result display page, I click Edit.
After clicking Edit, it should load the page which is a form with all the details in the fields for me to update.

What is the code for this?

Link to comment
Share on other sites

What is the code for this?

 

adminsearch.php:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>NMRR >> National Medical Research Registration</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>
<br><br><br><br><br><br>
<body>
<div id="Layer1" style="position:absolute; left:3px; top:15px; width:384px; height:100px; z-index:1"><img src="banner.png" width="777" height="104"></div>
<div id="Layer4" style="position:absolute; left:3px; top:120px; width:777px; height:8px; z-index:4"><img src="Hline.JPG" width="776" height="20"></div>
<div id="Layer7" style="position:absolute; left:367px; top:164px; width:248px; height:25px; z-index:7">
  <p align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Below 
    are the details.</strong></font></p>
</div>
<div id="Layer2" style="position:absolute; left:21px; top:151px; width:129px; height:32px; z-index:9"> 
<div align="right"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">
<?php echo date ('d F Y  ');?><br>
<?php echo date('H:i:s');?><br>
</font></div>

</div>
<p> </p>
<div id="Layer3" style="position:absolute; left:21px; top:206px; width:132px; height:140px; z-index:34"> 
  <table width="101%" border="0">
    <tr> 
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><a href="viewall_admin.php">View 
          All</a></strong></font></div></td>
    </tr>
    <tr> 
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><a href="updateform.php">Add 
          New Record</a></strong></font> </div></td>
    </tr>
    <tr> 
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><a href="adminlogin.php">Search</a></strong></font></div></td>
    </tr>
    <tr> 
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><a href="editform.php">Edit</a></strong></font></div></td>
    </tr>
    <tr>
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><a href="viewall_admin.php">Delete</a></strong></font></div></td>
    </tr>
    <tr>
      <td> </td>
    </tr>
    <tr> 
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><a href="adminlogin.php"><strong>[Back]</strong></a></font></div></td>
    </tr>
    <tr> 
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><a href="logout.php"><strong>[Logout]</strong></a></font></div></td>
    </tr>
  </table>
</div>
  <div id="Layer3" style="position:absolute; left:312px; top:202px; width:470px; height:254px; z-index:10"><?php include 'adminsearch_func.php';?> </div>
</body>
</html>

adminsearch_func.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>NMRR >> National Medical Research Registration</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>
<body>
<?php
//include 'edit.php';
//include 'delete.php';

	//declare variable
   $Search = $_POST["textfield"];

  	if ($Search == "")
  	{
		echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL=adminsearch_again.php">';
     	exit();
  	}
	
	$host="mysql17.000webhost.com"; // Host name
	$username="a6041704_crcnmrr"; // Mysql username
	$password="crc123"; // Mysql password
	$db_name="a6041704_crcnmrr"; // Database name
	$tbl_name="nmrr"; // Table name

   //make the database connection
   mysql_connect("$host", "$username", "$password")or die("cannot connect");
   mysql_select_db("$db_name")or die("cannot select DB");
 
   //create a SELECT query
   $sql = "SELECT nmrr, title, pi, site, dept FROM nmrr WHERE nmrr LIKE '%$Search%'";
   //$result = mysql_query($sql, $conn) or die(mysql_error());
   	$result=mysql_query($sql);
  
       //check for invalid data
       if (mysql_num_rows($result) < 1) 
        {
           echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL=search_again.php">';
           exit();
        }
      else
        {
           //draw table display details  
           while($row = mysql_fetch_assoc($result))
         {
             print "<table border = 1 width = 70%>\n";

      foreach($row as $key=>$val)
      {    
        $col = $row["id"];

        print "<tr>";
        print "<th width=10%>$key</th>";
        print "<td>$val</td>";
        print "</tr>";
      }//end foreach
	  	echo" <br>";
              }//end while
     }
?>
</body>
</html>

Edited by pingme81
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.