Jump to content

Recommended Posts

i have managed to retrieve emails into a textarea now i want to put code that can allow retrieve the next row using a button?here is my code so far.

help

 

include('Config.php');

$sql = "SELECT * FROM Email_Inb";
$query = mysql_query($sql);
               if (!$query) { // Handle error
                  echo 'Query failed. SQL: ', $sql, '<br />Error # ', mysql_errno(), ' Error msg: ', mysql_error();
                  exit;
                  }
             

while($row=mysql_fetch_array($query)){
  
  $theFid=$row['member_id'] ;//member"
  $themsg=$row['emailmsg'] ;//message
  $thedate=$row['recdate'] ;//date received
  $theid=$row['main_id'] ;//id
  };
  ?>


<style type="text/css">
<!--
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
}
-->
</style><title>Inbound emails</title>
<div align="center"><strong><span class="style1"><u>Email Inbound </u></span></strong></div>
<form id="form1" name="form1" method="post" action="">
  <table width="1015" border="0" align="center">
    <tr>
      <th width="2" scope="col"> </th>
      <th width="467" scope="col">Mode:-
        <select name="select">
        <option value="email" name="email">Email</option>
        <option value="SMS">SMS</option>
        
      </select>      </th>
      <th width="532" scope="col"> </th>
    </tr>
    <tr>
      <td> </td>
      <td align="center"><strong>Sender:-</strong>
        <input name="sender" type="text" id="sender" value="<?php echo $theFid ?>"/></td>
      <td> </td>
    </tr>
    <tr>
      <td height="77" rowspan="2"> </td>
      <td align="left"><strong>Message:-</strong></td>
      <td><strong>Reply:-</strong></td>
    </tr>
    <tr>
      <td align="center"><textarea name="msg" cols="75" id="msg" value="frrf"><?php echo $themsg ?></textarea></td>
      <td align="center"><textarea name="respond" cols="75" id="textarea"></textarea></td>
    </tr>
    <tr>
      <td> </td>
      <td align="center">
        
        <input type="submit" name="Submit3" value="  Next   " /></td>
      <td></td>
    </tr>
    <tr>
      <td> </td>
      <td align="center"> </td>
      <td> </td>
    </tr>
  </table>
</form>
<p> </p>

Okay, that's not too hard.

 

First, you have to get the last row in the database..

Second, you have to get the current row, plus one (that is the next row.

$nextrow = $currentrow + 1;

Then the button:

if ($currentrow == $lastrow) {
//last row reached, do not display next button
} else {
echo '<input type="submit" name="nextrow" value="$nextrow">';

 

And you will have to make an if and else statement. something like:

if (isset($_POST['nextrow'])) {
//do query for next row
} else {
//do query for first row
}

still no joy its not working.where its nw like this?

pliz help m new n php

 

<?php
   if ($_SERVER['REQUEST_METHOD'] != 'POST'){
      $me = $_SERVER['PHP_SELF'];
?>
   <form name="form1" method="post"
         action="<?php echo $me;?>">

   <table width="1177" border="0" align="center">
     <tr>
       <th width="323" nowrap scope="col">Select Respondents: 
         <select name="mychoice">
           <option value="Male" selected>Male</option>
           <option value="Female">Female</option>
                   <option value="All">All</option>
         </select>       </th>
       <th width="454" nowrap scope="col">Select Mode: 
         <select name="mymode">
           <option value="SMS">SMS</option>
                <option value="E-Mail">E-Mail</option>
       
         </select>       </th>
       <th width="386" align="left" nowrap scope="col">Select Auto Event Follow-up:
       
              </select></th>
     </tr>
     <tr>
       <td rowspan="3"> </td>
       <td align="center" nowrap><p><strong>Subject:</strong>
         <input name="thesubject" type="text" id="subject" size="35">
       </p>
         </td>
       <td rowspan="3" align="center"><input type="submit" name="Submit2" value="ADD CONTENT"></td>
     </tr>
     <tr>
       <td align="center" nowrap><strong>
        
       </strong></td>
     </tr>
     <tr>
       <td align="center"><textarea name="MsgBody" cols="50" rows="5"></textarea></td>
     </tr>
     <tr>
       <td> </td>
       <td align="center"><?php echo'<input type="submit" name="Submit" value="ADD CONTENT">' 
        switch($_POST['mychoice']){
            case 'Male':
               $recipient = mysql_query("SELECT * FROM PMember WHERE gender='m'");
		   mysql_query("INSERT INTO Out_Mail(member_id,subject,message) VALUES ('$recipient', '$_POST[thesubject]','$_POST[MsgBody]')");
               Print "Your information has been successfully added to the database."; 
               break;
            case 'female':
               $recipient = mysql_query("SELECT * FROM PMember WHERE gender='f'");
               mysql_query("INSERT INTO Out_Mail(member_id,subject,message) VALUES ('$recipient', '$_POST[thesubject]','$_POST[MsgBody]')");
               Print "Your information has been successfully added to the database."; 
		   break;
               		   
            default:
               $recipient = mysql_query("SELECT * FROM PMember");
		   mysql_query("INSERT INTO Out_Mail(member_id,subject,message) VALUES ('$recipient', '$_POST[thesubject]','$_POST[MsgBody]')");
              Print "Your information has been successfully sent."; } ?></td>
       <td> </td>
     </tr>
   </table>
   <div align="center"></div>
</form>

  

               
        // }
      
     
//}
?>

m tryng to query 2 different tables the first is to retrieve a single row then the second is to insert into a different table then i nid to navigate to the next row in the first table?????? the first query a user has to select from the pull down menu.

This code has nothing to do with your first question "Navigation my data records one by one", does it ?

 

So, what is the problem now? because I'm a bit lost....

Ow and could you check your spelling with a spelling checker? Thanks!

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.