Please help me to modify my java code from php code

Please help me to modify my java code from php code

i want to covert this php code int java/JSP .

if (isset($_POST['orders'])) {

$orders = explode('&', $_POST['orders']);
$array = array();

foreach($orders as $item) {
    $item = explode('=', $item);
    $item = explode('_', $item[1]);
    $array[] = $item[1];
}

} I tried like this (see below JSP code) ... but this is not giving me the exact result as the above PHP code is giving. So please help me to convert it into Java.

if (request.getParameter("orders") != null) { String item = request.getParameter("orders"); System.out.println("oRDERS...."+item);

String[] arr = item.split("\\=");
item.split("\\_");

System.out.println("Length of Array is :" + arr.length);

for (int i = 0; i < arr.length; i++) {
     System.out.println("array " + i + ":" + arr[i]);
}

} else { System.out.println("NOT SET"); }

View Answers

April 2, 2012 at 11:42 AM

We are providing you the code where we have specified only three fields bookid,author and title in the database. Follow these steps to update these fields:

1) Create book.jsp

    <%@page import="java.sql.*"%>

    <form name=myname method=post action="edit.jsp">
    <table border="1">
    <tr><td></td>
    <td><b><u>bookid</u></b></td>
    <td><b><u>Author</u></b></td>
    <td><b><u>title</u></b></td>
    </tr>
    <%try{

    Connection conn = null;
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root", "root");
    ResultSet rs = null;
    Statement st=null;
    st=conn.createStatement();
    rs = st.executeQuery("select * from book");
    int i=0; while(rs.next()){ %>
    <tr><td><input type="checkbox" name="check<%=i%>" value=<%= rs.getString("bookid") %>></td>
    <td><%= rs.getString("bookid") %></td>
    <td><%= rs.getString("author") %></td>
    <td><%= rs.getString("title") %></td>
    </tr><%
    i++;
    }
%>
<input type="hidden" name="value" value="<%=i%>">
<%
    }catch(SQLException e){ System.out.println(e.getMessage()); } %>
    </table>
    <input type="submit">
    </form>

2) Create edit.jsp

    <%@page import="java.sql.*"%>

    <%
String v=request.getParameter("value");
String id[]= new String[Integer.parseInt(v)];
    for(int i=0;i<10;i++){
    id[i]=request.getParameter("check"+i);
    out.println(id[i]);
    }
    %>

    <form name=myname method=post action="update.jsp">
    <table border="1">
    <tr>
    <td><b><u>bookid</u></b></td>
    <td><b><u>Author</u></b></td>
    <td><b><u>title</u></b></td>
    </tr>
    <%try{

    Connection conn = null;
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root", "root");
    ResultSet rs = null;
    Statement st=null;
    st=conn.createStatement();
    for(int a=0;a<10;a++){
    rs = st.executeQuery("select * from book where bookid='"+id[a]+"'");
    while(rs.next()){ %>
    <tr>
    <td><input type="text" name="bid" value="<%= rs.getString("bookid") %>"></td>
    <td><input type="text" name="auth" value="<%= rs.getString("author") %>"></td>
    <td><input type="text" name="tit" value="<%= rs.getString("title") %>"></td>
    </tr><%
    }
    }
    }catch(SQLException e){ System.out.println(e.getMessage()); } %>
    </table>

    <input type="submit">

April 2, 2012 at 11:43 AM

continue..

3)Create update.jsp

<%@page import="java.sql.*"%>
<%
String d[] =request.getParameterValues("bid");
if(d !=null) {
for(int i=0;i<d.length;i++) {
out.println(d[i]);
}
}
String name[] =request.getParameterValues("auth");
if(name !=null) {
for(int i=0;i<name.length;i++) {
out.println(name[i]);
}
}
String title[] =request.getParameterValues("tit");
if(title !=null) {
for(int i=0;i<title.length;i++) {
out.println(title[i]);
}
}
%>
<%
try{
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root", "root");

Statement st=null;
st=conn.createStatement();
for(int a=0;a<10;a++){
String book_id=d[a];
String author=name[a];
String tit=title[a];
st.executeUpdate("update book set author='"+author+"', title='"+tit+"' where bookid='"+book_id+"'");
}
}
catch(Exception e){
e.printStackTrace();
}
%>

April 4, 2012 at 8:51 AM

Thank you , But this not my exact solution for my problem. What actually i want to do is "i want to order my table rows, users drag and drop the rows in the browser and same order should be stored in my books table(database) in the order column. So that when they refresh the page their order should be remain same, as they alter it before. Please help me on this topic "how to order rows?"









Related Tutorials/Questions & Answers:
Please help me to modify my java code from php code
Modify Java code from PHP Code  i want to covert this php code int...]; } } I tried like this (see below JSP code) ... but this is not giving me the exact result as the above PHP code is giving. So please help me to convert
Please help me to modify my java code from php code
Please help me to modify my java code from php code  i want to covert this php code int java/JSP . if (isset($_POST['orders'])) { $orders...) ... but this is not giving me the exact result as the above PHP code is giving. So please
Advertisements
I need help on my Java code.... please please help me out!?
I need help on my Java code.... please please help me out!?  Well my... in the file. Also it should be displayed on the screen. However my code doesn't display the anagram on screen or the output file! Please show me whats wrong. Thanks i
this is my javascript code and i am not understanding the mistake in this,please help me?
this is my javascript code and i am not understanding the mistake in this,please help me?  <html> <h2>Form Validation</h2>...; if((nn1.value==null)||(nn1.value=="")){ alert("Please Enter
please help me to give code - Java Beginners
please help me to give code  Write a function with a signature cheerlead(word) that prints a typical cheer as follows. The word robot: Gimme an R Gimme an O Gimme a B Gimme an O Gimme a T What did you give me? ROBOT
please help me to give code - Java Beginners
please help me to give code  Write a function, sliding(word, num)that behaves as follows. It should print out each slice of the original word having length num, aligned vertically as shown below. A call to sliding(examples, 4
please help me to give code - Java Beginners
please help me to give code  Write a program that uses loops to generate an n x n times table. The program should get n from the user. As a model here is a 4 x4 version: | 1 2 3 4
please help me to give code - Java Beginners
please help me to give code  Write a program that prints an n-level stair case made of text. The user should choose the text character..., http://www.roseindia.net/java
please help me to give code - Java Beginners
please help me to give code  Write a program that reads a file named famous.txt and prints out the line with the longest length. In the case...(); } } } ------------------------------- read for more information, http://www.roseindia.net/java/beginners/read
please help me to write a code for this program
please help me to write a code for this program   1 1 1 1 2 2 1 1 3 4 3 1 1 4 7 7 4 1
please help me to write a code for this program
please help me to write a code for this program   1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
Not sure whats wrong with my code HELP PLEASE?!?!
Not sure whats wrong with my code HELP PLEASE?!?!  I cant figure out what I am doing wrong in my code can anyone help me out??? Grades ADS_TO_REPLACE_1 function computeGrade( ) { var hw, lab, midt, fin, avg; hw
Please help me fix this code - MobileApplications
Please help me fix this code   Please help me in this area of code... in the background of the forms in this code i want to sum all expenses amount... expenses)", "Please fill all required field \n \n * This signify required field
PLZ HELP ME. i need php code.
PLZ HELP ME. i need php code.   I want php code for bellow OUTPUT. output is just example but it must be letters only. abc bcd efg jku rgt azs hje qqc wws adt
Can any one please help me in this ,,,,,,, need java code for this ,,,,please anyone
Can any one please help me in this ,,,,,,, need java code for this ,,,,please anyone  The Airport Valet Parking Company (AVP) is a company which... in an numbered parking bay at the storage location not far from the airport. The car key
please any one can help me to write a code for this question?
please any one can help me to write a code for this question?  1) Copy one file content to other? 2) Count the number of words in a file
Please help me to write a code for add contacts to groups in a website?
Please help me to write a code for add contacts to groups in a website?   Iam developing a site. In that site I need to write code for Groups... send a code for this? Please make it fast
please any one can help me to write a code for this question?
please any one can help me to write a code for this question?  Q 1) In a class first day 25 students are joined. After two days that total students will increased to 60. We can develop a program by using ArrayList concept
Please help with this code
Please help with this code  I need some help getting the Search method below to work with the menu, and I also cannot figure out how to get my bubble sort to work. I've spent a long time on this and think my brain is just fried
Need someone to check and modify my simple code - Java Beginners
Need someone to check and modify my simple code   How to write a class that contains Variables that hold hourly rate of pay, number of hours...); } }   Hi Friend, You can use following code: import
Help me please with my final homework
Help me please with my final homework  Write a Java program of your choice that demonstrates the following concepts: ? Input and Output. ? Selection/Conditional (e.g. if statement). ? Arithmetic. ? Loops. ? Arrays
Plz help me in writing the code - Java Beginners
Plz help me in writing the code   Write a two user Chess Game. (users must be on different systems
Plz help me in writing the code - Java Beginners
Plz help me in writing the code   Write a two user Chess Game. (users must be on different systems
PLEASE HELP WITH MY JAVA
PLEASE HELP WITH MY JAVA  Hey my name is Gavin and im a student at school that takes IT. my teacher has gave me a problem and i can't figure it out please help!!!!!!!! it is a for-loop question: Display the first 5 multiples
i want to find the byte code of a image file ... for my project..plz if anybody help me for java coding i will grateful..
i want to find the byte code of a image file ... for my project..plz if anybody help me for java coding i will grateful..   i want to convert a image file to its byte code format that help me for the pattern matching in my
could anyone please help with the code.
could anyone please help with the code.  protected void doPost...(request, response); } } could anyone please check the code. If i enter... all the details from the jsp page */ System.out.println("inside action
i want java code for this xml file...please show me..
i want java code for this xml file...please show me..   xbrli:shares xbrli:pure iso4217:INR
Help me please!!! - Java Beginners
Help me please!!!  im badly needing the complete code for this project in java!!! can you please help me???!!! it is about 1-dimensional array... the answers 8Hours from now!!! Kindly help me!! please!!please!!! NOTE
ajax code please help to solve this........
ajax code please help to solve this.  in this i am trying to get data from datbase and put it in combo box and then display it down using table...; } please help me when i am running this it show an error
why above code returning the value of squares is 82... even after returning an increnented value of squares... please help me...
why above code returning the value of squares is 82... even after returning an increnented value of squares... please help me...   public class d55 { int squares = 81; public static void main(String
please send me javascript validation code - Java Beginners
please send me javascript validation code  hallo sir , please send me java script code for this html page.since i want to do validation.i am a new user in java ....please send me its urgent
please help me - Java Beginners
please help me   I have some error in this programe //write acomputer programe using java to generate following series : //output: //1,2,3,0... have done modification in your code and here is the code according to the series
Please give me the code for the below problem - Java Interview Questions
Please give me the code for the below problem  PROBLEM : SALES TAXES Basic sales tax is applicable at a rate of 10% on all goods, except books... Vidya  Hi Friend, Try the following code: import java.util.
Help Me in My Java Work
Help Me in My Java Work  Can you help me please... Write a Java... for individual marks are given below: (i) A mark ranging from 90 to 100% is awarded a GPA of 4.0 (ii) A mark ranging from 80 to 89%: is awarded a GPA of 3.5. (iii
Pleae help me to give logic and code for this program - Java Beginners
Pleae help me to give logic and code for this program  Write... consecutive copies of each letter from the original string. For example...://www.roseindia.net/java/beginners/StringReverseUsingStringUtils.shtml
Please tell me the code to generate the below structure
Please tell me the code to generate the below structure  1 2 3 4 5 6 7 8 9 1 2 3 4 6 7 8 9 1 2 3 7 8 9 1 2 8 9 1 9 1 2 8 9 1 2 3 7 8 9 1 2 3 4 6 7 8 9 1 2 3
please convert for me this code to GUI - Swing AWT
please convert for me this code to GUI    THE CODES ARE BELOW...; } else screen.displayMessageLine( "\nInvalid account Nummber or PIN, Please...() { screen.displayMessageLine("\nMain Menu:"); screen.displayMessageLine("1-View my
urgent...pleAse help me.....please!
urgent...pleAse help me.....please!  please help me urgent! how can i do dictionary with the use of array code in java, where i will type the word then the corresponding meaning for that word will appear...thanks
please convert for me this code to GUI - Swing AWT
please convert for me this code to GUI  THE CODES ARE BELOW, CLASS... account Nummber or PIN, Please try again."); } private void...() { screen.displayMessageLine("\nMain Menu:"); screen.displayMessageLine("1-View my balance
please help me.
please help me.  Please send me a code of template in opencms and its procedure.so i can implement the code. Thanks trinath
please help me.
please help me.  How to read a properties file in java with a suitable example. Please send me. Thanks Trinath   Please visit the following link: Java read properties file
please help me
before. This name list should get from the database. Please help me. By the way, I'm...please help me  Dear sir, I have a problem. How to write JSP coding, if a user select a value from drop down list for example department, the another
Can anybody help me with this simple MySql code
Can anybody help me with this simple MySql code  select c.countryid, r.bp, r.sp, c.country, t.timee from rate as r, countryloc as c, todaysrate as t... || []).push({}); can any one help me with the query because i want to select al
please help me in a java program !! - Java Beginners
please help me in a java program !!  the porgram should use...://en.wikipedia.org/wiki/Kosaraju_algorithm) there are 4 classes in my program : Vertex , StackX, Graph , DFSApp "DFSApp is the one from which i modify the graph
i want to create website,with manu with three level submenu on top side of page please send me code java
i want to create website,with manu with three level submenu on top side of page please send me code java   iam createing wibsite thats using eclipse andtomcat server,please help me to write menu with three level submenu
sir, how to convert excel file to csv file using java? please send me sample code.
sir, how to convert excel file to csv file using java? please send me sample code.  please send me sample code for converting excel file into csv file uisng java
Please help me.
Please help me.  Hi i am trinath in below there is a url.In that url there is a code of edit a jsp page.I understand that code but only one thing i not get it i.e; What is the work of "id".and what is the data type of id? http
please help me to overcome this problem
please help me to overcome this problem  how to make it easy to write java code. can u please give me suggestions
please help me.
please help me.  I have a jsp page under that i add a list box under i get the countries through my database. so how can i do
please help me.
please help me.  Please send me the validation of this below link. the link is http://www.roseindia.net/answers/viewqa/JSP-Servlet/9584-JSP-Servlet-Search-and-Edit.html Thanks Trinath

Ads