vikela Posted March 9, 2009 Share Posted March 9, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/148583-cursornavigating-my-data-records-one-by-one/ Share on other sites More sharing options...
DjMikeS Posted March 9, 2009 Share Posted March 9, 2009 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 } Quote Link to comment https://forums.phpfreaks.com/topic/148583-cursornavigating-my-data-records-one-by-one/#findComment-780241 Share on other sites More sharing options...
Adam Posted March 9, 2009 Share Posted March 9, 2009 The MySQL behind it.. $rowToGet = 5; // bare in mind results will start at 0 so 5 will return result 6 $query = mysql_query("SELECT * FROM Email_Inb LIMIT ".$rowToGet.", 1"); Hope this helps.. Adam Quote Link to comment https://forums.phpfreaks.com/topic/148583-cursornavigating-my-data-records-one-by-one/#findComment-780248 Share on other sites More sharing options...
vikela Posted March 9, 2009 Author Share Posted March 9, 2009 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> // } //} ?> Quote Link to comment https://forums.phpfreaks.com/topic/148583-cursornavigating-my-data-records-one-by-one/#findComment-780361 Share on other sites More sharing options...
Adam Posted March 9, 2009 Share Posted March 9, 2009 ...eh? That's pretty different code to your first post. Which query exactly are you trying to cycle through? Adam Quote Link to comment https://forums.phpfreaks.com/topic/148583-cursornavigating-my-data-records-one-by-one/#findComment-780366 Share on other sites More sharing options...
vikela Posted March 9, 2009 Author Share Posted March 9, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/148583-cursornavigating-my-data-records-one-by-one/#findComment-780377 Share on other sites More sharing options...
DjMikeS Posted March 9, 2009 Share Posted March 9, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/148583-cursornavigating-my-data-records-one-by-one/#findComment-780381 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.