|
|
|
ต้องการ insert ข้อมูลลงฐานข้อมูลคะโดยใช้ mysql_num_fields ดึงชื่อ column ขึ้นมา |
|
|
|
|
|
|
|
ตรงไหนครับ คำสั่ง Insert
|
|
|
|
|
Date :
2013-02-06 13:57:13 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// หน้า add row.php
Code (PHP)
<?php include("../web server info login/inc/left.php") ?>
<br><br>
<form align="center" action="addrow_process.php" method="post" name="form1" onSubmit="JavaScript:return fncSubmit();" enctype="multipart/form-data">
<center>
<?php
$con = mysql_connect("localhost", "root", "");
$db_selected = mysql_select_db("vas_server",$con);
$result = mysql_query("select * from info", $con);
?>
<table width="50%" >
<tr align="center" bgcolor="#b6b684"><font size="2">
<td width="25%" ><b><h3>Field Name </b></div></td>
<td width="25%"><b><h3>Details </b></div></td>
</tr></font>
<tr bgcolor="#eeeec3">
<td align="center"><h3><b>Picture</b></td>
<td align="center"><input type="file" name="fileUpload"><br>
</td>
<tr bgcolor="#eeeec3">
<td align="center"><h3>sys_name</td>
<td align="center"><input name="ss" type="text" id="ss"></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>server_name</td>
<td align="center"><input name="a" type="text" id="a"></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>equip_spec</td>
<td align="center"><input name="b" type="text" id="b"></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>type_equip</td>
<td align="center"><input name="c" type="text" id="c" ></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>service</td>
<td align="center"><input name="d" type="text" id="d" ></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>nri_service</td>
<td align="center"><input name="e" type="text" id="e"></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>AC/DC</td>
<td align="center"><input name="bad" type="text" id="bad" ></td>
</tr><tr bgcolor="#eeeec3">
<td align="center"><h3>num_source</td>
<td align="center"><input name="g" type="text" id="g"></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>power_1</td>
<td align="center"><input name="h" type="text" id="h" ></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>CB1</td>
<td align="center"><input name="i" type="text" id="i"></td>
</tr><tr bgcolor="#eeeec3">
<td align="center"><h3>power_2</td>
<td align="center"><input name="j" type="text" id="j" ></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>CB2</td>
<td align="center"><input name="k" type="text" id="k"></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>power_3</td>
<td align="center"><input name="l" type="text" id="l" ></td>
</tr><tr bgcolor="#eeeec3">
<td align="center"><h3>CB3</td>
<td align="center"><input name="m" type="text" id="m" ></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>rack_name</td>
<td align="center"><input name="n" type="text" id="n" ></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>rack_loc</td>
<td align="center"><input name="o" type="text" id="o" ></td>
</tr><tr bgcolor="#eeeec3">
<td align="center"><h3>site</td>
<td align="center"><input name="p" type="text" id="p" ></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>floor</td>
<td align="center"><input name="q" type="text" id="q" ></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>room</td>
<td align="center"><input name="r" type="text" id="r"></td>
</tr><tr bgcolor="#eeeec3">
<td align="center"><h3>serial</td>
<td align="center"><input name="s" type="text" id="s" ></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>ip</td>
<td align="center"><input name="t" type="text" id="t" ></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>mac</td>
<td align="center"><input name="u" type="text" id="u" ></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>sys_os</td>
<td align="center"><input name="v" type="text" id="v" ></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>db_os</td>
<td align="center"><input name="w" type="text" id="w" ></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>vendor_hw</td>
<td align="center"><input name="x" type="text" id="x" ></td>
</tr><tr bgcolor="#eeeec3">
<td align="center"><h3>vendor_sw</td>
<td align="center"><input name="y" type="text" id="y" ></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>note</td>
<td align="center"><input name="z" type="text" id="z" ></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>effect</td>
<td align="center"><input name="aa" type="text" id="aa" ></td>
</tr><tr bgcolor="#eeeec3">
<td align="center"><h3>team</td>
<td align="center"><input name="bb" type="text" id="bb"></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center"><h3>hostname</td>
<td align="center"><input name="cc" type="text" id="cc" ></td>
</tr>
<tr bgcolor="#eeeec3">
<td align="center" >
<?php $i = 33;
while ($i < mysql_num_fields($result))
{
?>
<h3>
<?php
$sum = mysql_field_name($result,$i) . "<br />" . "<hr color='white'>";
echo $sum;
$i++;
}
?>
</td>
<td align="center">
<?php
$i = 33;
while ($i < mysql_num_fields($result))
{
?>
<input name="a" type="text" id="a" >
<?php
echo '<br />' . "<hr color='white'>";
$i++;
}
?>
|
|
|
|
|
Date :
2013-02-07 11:44:46 |
By :
Guest |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// หน้า add row process.php
// ต้องเขียนหน้า add row process อย่างไรค่ะ
Code (PHP)
<?php
ob_start();
if(trim($_FILES["fileUpload"]["tmp_name"]) != "")
{
$images = $_FILES["fileUpload"]["tmp_name"];
$new_images = "Thumbnails_".$_FILES["fileUpload"]["name"];
copy($_FILES["fileUpload"]["tmp_name"],"MyResize/".$_FILES["fileUpload"]["name"]);
$width=100; //*** Fix Width & Heigh (Autu caculate) ***//
$size=GetimageSize($images);
$height=round($width*$size[1]/$size[0]);
if($width > $height){
$width=400;
$height=300;}
else{
$width=400;
$height=533; }
$images_orig = ImageCreateFromJPEG($images);
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
ImageJPEG($images_fin,"MyResize/".$new_images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
$objConnect = mysql_connect("localhost", "root", "") or die("Error Connection to Database");
$objDB = mysql_select_db("vas_server");
$strSQL = "INSERT INTO info (pic,sys_name, server_name, equip_spec, type_equip, service, nri_service, AC_DC, num_source, power_1, CB1, power_2, CB2,power_3, CB3, rack_name, rack_loc, site, floor, room, serial, ip, mac, sys_os, db_os, vendor_hw, vendor_sw, note, effect, team, hostname,$sum ) VALUES('".$new_images."','".$_POST["ss"]."','".$_POST["a"]."' ,'".$_POST["b"]."','".$_POST["c"]."','".$_POST["d"]."' ,'".$_POST["e"]."','".$_POST["bad"]."','".$_POST["g"]."' ,'".$_POST["h"]."','".$_POST["i"]."','".$_POST["j"]."', '".$_POST["k"]."','".$_POST["l"]."','".$_POST["m"]."','".$_POST["n"]."' ,'".$_POST["o"]."','".$_POST["p"]."','".$_POST["q"]."','".$_POST["r"]."' ,'".$_POST["s"]."','".$_POST["t"]."','".$_POST["u"]."','".$_POST["v"]."', '".$_POST["w"]."','".$_POST["x"]."','".$_POST["y"]."','".$_POST["z"]."','".$_POST["aa"]."','".$_POST["bb"]."','".$_POST["cc"]."','".$_POST["a"]."')";
$objQuery = mysql_query($strSQL);
if(!$objQuery){
echo "Error Insert [".$strSQL."]";
}
//echo "<pre>\n";
//print_r($_FILES);
//echo "</pre>\n";
}
//header("location:index.php");
?>
|
|
|
|
|
Date :
2013-02-07 11:46:12 |
By :
Guest |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|