Dear all,
my PHP aims to update a MySQL database by selecting record
one by one and modify then save.
Here are my PHP, but I found that it doesnt work as it supposed to be,
for example, when Record (i) is shown and modified, the change will
come to Record (i+1).
Can anyone provide suggestion?
thanks.
<?php
$connect = mysql_connect(" andy","kiong"," Password")or
die("Could not connect : " . mysql_error()); ;
mysql_select_db ("kiong_userinf o",$connect) or die("Could not
connect : " . mysql_error());
$result = mysql_query("SE LECT * FROM putonServer where id2=1",
$connect);
printf("%s<br>\ n", mysql_result($r esult,0,"body") );
?>
<table width="556" height="70" border="0"
align="center">
<tr>
<td width="59" height="66">&nb sp;</td>
</tr>
</table>
<p align="center">
<?php
$this_id=mysql_ result($result, 0,"id");
$next_id=$this_ id+1;
$cat=mysql_resu lt($result,0,"c ategory");
$newline = "<br />";
if($cat==1)
{
echo "Process".$newl ine;
echo $newline;
}elseif($cat==2 )
{
echo "Product".$newl ine;
echo $newline;
}else{
echo "People".$newli ne;
echo $newline;
}
$ori=mysql_resu lt($result,0,"o rientation");
echo "$ori";
?>
<?php
$connect = mysql_connect(" Server","kiong" ,"Password") or
die("Could not connect : " . mysql_error());
$db_selected = mysql_select_db ("kiong_userinf o",
$connect);
if (!$db_selected) {
die ('Can\'t use foo : ' . mysql_error());
}
if($_POST[B2]){
$query_B2 ="UPDATE putonServer SET
category='$_POS T[R2]',orientation=' $_POST[sliderinput22]' where
id='$this_id'";
echo $this_id.$newli ne;
$result_B2=mysq l_query($query_ B2,$connect);
if (!$result_B2) {
die ('Puke, Wrong2 ' . mysql_error());
}
$query_B2_1="up date putonServer SET id2=4 where
id='$this_id'";
echo $this_id.$newli ne;
$query_B2_2="up date putonServer SET id2=1 where
id='$next_id'";
echo $this_id.$newli ne;
$result_B2_2=my sql_query($quer y_B2_2,$connect );
if (!$result_B2_2) {
die ('Puke, Wrong ' . mysql_error());
}
$result_B2_1=my sql_query($quer y_B2_1,$connect );
if (!$result_B2_1) {
die ('Puke, Wrong2 ' . mysql_error());
}
}elseif($_POST[B0]){
$query_B0="upda te putonServer SET id2=7 where id='$this_id'";
$query_B0_2="up date putonServer SET id2=1 where
id='$next_id'";
$result_B0=mysq l_query($query_ B0,$connect);
if (!$result_B0) {
die ('Puke, Wrong2 ' . mysql_error());
}
$result_B0_2=my sql_query($quer y_B0_2,$connect );
if (!$result_B0_2) {
die ('Puke, Wrong ' . mysql_error());
}
}elseif($_POST[B1]){
$query_B1="upda te putonServer SET id2=0 where id='$this_id'";
$query_B1_2="up date putonServer SET id2=1 where
id='$next_id'";
$result_B1=mysq l_query($query_ B1,$connect);
if (!$result_B1) {
die ('Puke, Wrong2 ' . mysql_error());
}
$result_B1_2=my sql_query($quer y_B1_2,$connect );
if (!$result_B1_2) {
die ('Puke, Wrong ' . mysql_error());
}
}
?>
my PHP aims to update a MySQL database by selecting record
one by one and modify then save.
Here are my PHP, but I found that it doesnt work as it supposed to be,
for example, when Record (i) is shown and modified, the change will
come to Record (i+1).
Can anyone provide suggestion?
thanks.
<?php
$connect = mysql_connect(" andy","kiong"," Password")or
die("Could not connect : " . mysql_error()); ;
mysql_select_db ("kiong_userinf o",$connect) or die("Could not
connect : " . mysql_error());
$result = mysql_query("SE LECT * FROM putonServer where id2=1",
$connect);
printf("%s<br>\ n", mysql_result($r esult,0,"body") );
?>
<table width="556" height="70" border="0"
align="center">
<tr>
<td width="59" height="66">&nb sp;</td>
</tr>
</table>
<p align="center">
<?php
$this_id=mysql_ result($result, 0,"id");
$next_id=$this_ id+1;
$cat=mysql_resu lt($result,0,"c ategory");
$newline = "<br />";
if($cat==1)
{
echo "Process".$newl ine;
echo $newline;
}elseif($cat==2 )
{
echo "Product".$newl ine;
echo $newline;
}else{
echo "People".$newli ne;
echo $newline;
}
$ori=mysql_resu lt($result,0,"o rientation");
echo "$ori";
?>
<?php
$connect = mysql_connect(" Server","kiong" ,"Password") or
die("Could not connect : " . mysql_error());
$db_selected = mysql_select_db ("kiong_userinf o",
$connect);
if (!$db_selected) {
die ('Can\'t use foo : ' . mysql_error());
}
if($_POST[B2]){
$query_B2 ="UPDATE putonServer SET
category='$_POS T[R2]',orientation=' $_POST[sliderinput22]' where
id='$this_id'";
echo $this_id.$newli ne;
$result_B2=mysq l_query($query_ B2,$connect);
if (!$result_B2) {
die ('Puke, Wrong2 ' . mysql_error());
}
$query_B2_1="up date putonServer SET id2=4 where
id='$this_id'";
echo $this_id.$newli ne;
$query_B2_2="up date putonServer SET id2=1 where
id='$next_id'";
echo $this_id.$newli ne;
$result_B2_2=my sql_query($quer y_B2_2,$connect );
if (!$result_B2_2) {
die ('Puke, Wrong ' . mysql_error());
}
$result_B2_1=my sql_query($quer y_B2_1,$connect );
if (!$result_B2_1) {
die ('Puke, Wrong2 ' . mysql_error());
}
}elseif($_POST[B0]){
$query_B0="upda te putonServer SET id2=7 where id='$this_id'";
$query_B0_2="up date putonServer SET id2=1 where
id='$next_id'";
$result_B0=mysq l_query($query_ B0,$connect);
if (!$result_B0) {
die ('Puke, Wrong2 ' . mysql_error());
}
$result_B0_2=my sql_query($quer y_B0_2,$connect );
if (!$result_B0_2) {
die ('Puke, Wrong ' . mysql_error());
}
}elseif($_POST[B1]){
$query_B1="upda te putonServer SET id2=0 where id='$this_id'";
$query_B1_2="up date putonServer SET id2=1 where
id='$next_id'";
$result_B1=mysq l_query($query_ B1,$connect);
if (!$result_B1) {
die ('Puke, Wrong2 ' . mysql_error());
}
$result_B1_2=my sql_query($quer y_B1_2,$connect );
if (!$result_B1_2) {
die ('Puke, Wrong ' . mysql_error());
}
}
?>
Comment