Hi to all
I have designed a entry page which is used to INSERT Data in a Daatabse table.
I use meta fresh tag time =60seconds
Now I want to show that in another page with 2 control buttons ACCEPT and REJECT.

Problems:

1. I need to show only one row from databse for example row1 then row 2.
2. When some one press ACCEPT it sneds message to onother person that this INSERTION is ACCEPTED.
3. When someone REJECTS it delete the data from databse and sends message to the entry user that this record Rejected.

Is it posssible?

Hi

You have to take different forms as form1 and form2 for accept,reject....

I think this is also one way..try to this..

I show some data from table now I have 2 forms but how message will be shown only one from a databse .

Hi

after submitting ACCEPT OR REJECT ,

u need to use like this to display single message..

if(isset($_post['accept'] ))

{

//display message here....

}

like this another one also..

If is there any misunderstanding in this query, i am sorry...

friend I cant explain my question well, can i show u illustration What I want to do?

>1. I need to show only one row from databse for example row1 then row 2.

Fetch all rows from the table and add them to an array. Once all rows are added to an array then create session key to hold an array.

The following code might help you.

<?php
  
  # Fetch table result and store all rows into an array
  if(!isset($_SESSION["data"])) {
        # Write a code to fetch data from table and assign them
        # to an array named $m[].
        # For example,
        $m[]=Array("no"=>10,"name"=>"Mr.A");
        $m[]=Array("no"=>11,"name"=>"Mr.B");
        $m[]=Array("no"=>12,"name"=>"Mr.C");
        $m[]=Array("no"=>13,"name"=>"Mr.D");

        $_SESSION["data"]=m;
  }
  $m=$_SESSION["data"];
  $i=$_REQUEST["index"];
  if(!isset($i))
      $i=0;
	  
   $cmd=$_REQUEST["cmd"];


   if(isset($cmd)) {
        if($cmd=="Accept")  {
               # Write code to insert
               #     ...
               # Advanced a record. 
	   $i++;
                }
         else
          if($cmd=="Reject") {
               # Write your code to delete.
          }
         if($i<0)
	    $i=0;
          if($i>=count($m))
	$i=cuont($m)-1; 				 
   }
?>
<b>Current Record </b> : 
<?php 
  echo ($i+1); 
  echo  "/";
  echo  count($m);
?><br/>
<form method="post" action="Main1.php">
 <input type="hidden" value="<?php echo $i?>" name="index"/>
  <table border="2" width="400px	">
     <?php print_r($m[$i]);  ?>
   </table>
   <hr/>
   <input type="submit" name="cmd" value="Reject"/>
   <input type="submit" name="cmd" value="Accept"/>
</form>

Is there any simple query

$result = mysql_query("SELECT * FROM table
WHERE SiteId='$a' ");


while($row = mysql_fetch_array($result))
  {
code...
}

now how i can show just one record which is latest in database.

If I press Accept Button it accepted and message will sned to poster for exmaple entry operator that your entry is accepted.

If I press Reject only this specific information deleted from the Database and message send to poster that your entry is not accepted and (secereltly deleted from the database)

I can show u illustration ...
Can I?

Please check this Illustration. and how its possible.

Please check this illustration.

Please check this illustration.

I think you should follow this steps.

1. Display all record from say Table - X.
2. If you pressed Accept then Copy this record into table Y and delete it from table X.
3. If "Reject" is pressed then delete it from table - x.

Thats Really cool but how copy from one table to another.
I have no idea.

Plesae tell me how to copy two tables

I regret. I have used "Copy" which mean insert.

I wrote:
I think you should follow this steps.

1. Display all record from say Table - X.
2. If you pressed Accept then (Copy) insert this record into table Y and delete it from table X.
3. If "Reject" is pressed then delete it from table - x.

okz thanks :)

please tell me how I can get one row from the databse dynamically with update option and message sending option.

please tell me how I can get one row from the databse dynamically with update option and message sending option.

I have number of ways to solve your problem. Since last two days you haven't post your code yet - So, tell me is it the proper way to ask help?

Please post your code with BB code tag or zip it and attach with next reply.

This is a code which shows data from table

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

$result = mysql_query("SELECT * FROM abc");

echo "<table border='1'>
<tr>
<th >id</th>
<th>Name</th>
<th>City</th>";

while($row = mysql_fetch_array($result))
  {
    echo "<tr>" . $row['0'] ."</tr>";
	echo "<tr>";
	echo "<td>" . $row['Id'] . "</td>";
   echo "<td>" . $row['Name'] . "</td>";
  echo "<td>" . $row['City'] . "</td>";
  echo "<br />";
  echo "</tr>";
  }
  echo "</table>";
?>

I do not know how to show just one record (one row dynamically) witout Where Clause with ACCEPT and REJECT BUTTON.


if there are 5 records in databse all shown with their seperate ACCEPT and REJECT Buttons.

or any idea to use checkk boxes but it will difficult for me.

I have used following table structure:

Value of status field can be :
N.A - if it is a new record.
Accept - if it is accpted
Reject - if it is rejected

CREATE TABLE `testtable` (
`recid` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR( 40 ) NOT NULL ,
`address` VARCHAR( 40 ) NOT NULL ,
`city` VARCHAR( 40 ) NOT NULL ,
`status` VARCHAR( 40 ) NOT NULL DEFAULT 'N.A') ENGINE = MYISAM ;

and this is app.php

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

  $cmd=$_REQUEST["cmd"];
  $recid=$_REQUEST["recid"];
  if(isset($cmd)) {
     if($cmd=="Accept") {
       $sql="update testtable set status='Accept' where recid=$recid";
       mysql_query($sql);
     }
     if($cmd=="Reject") {
       $sql="update testtable set status='Reject' where recid=$recid";
       mysql_query($sql);
     }
  } 


$result = mysql_query("SELECT * FROM testtable where status='N.A'");


while($row = mysql_fetch_array($result))
  {
$form=<<<POST
<form method="post" action="app.php">
   <input type="hidden" name="recid" value="$row[0]"/>
   <table border="1">
      <tr>
       <td>Name</td><td>Address</td><td>City</td>
      </tr>
         <tr>
       <td>$row[1]</td><td>$row[2]</td><td>$row[3]</td>
      </tr>
      <tr>
        <td colspan="3">
           <input type="submit" name="cmd" value="Accept"/>
           <input type="submit" name="cmd" value="Reject"/>
        </td>
      </tr>
   </table> 
</form>

POST;

echo $form;
  }
?>

Solved: Thanks Adapost. you are genious.... thank you so much.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.