Jump to content

iNko

Members
  • Posts

    49
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

iNko's Achievements

Member

Member (2/5)

0

Reputation

  1. There is this url - http://xkcd.com/1110/ . It has an interactive image, witch is made out of 225 other images (its very big). I want to make a php script that would download all those 225 images. For example - http://imgs.xkcd.com/clickdrag/1n8w.png. 1n8w.png is one of those images, if i write 1n9w.png it would load another image. I think i do not explain myself well enough, so i am going to post how other ppl got the images but using other method: I do not know what DOS shell is, or what those command lines are, i do understand what that code does tho. Is it possible to make something like this but with php?
  2. cant edit.. SELECT Table1.sukurimo_data, Table2.issiuntimo_data, Table3.issiuntimo_data FROM Table1, Table2, Table3 WHERE Table1.table_id= Table2.table_id OR Table1.table_id= Table3.table_id This is how its displayed to me: how can i do this?? Edit: also when i try this: SELECT table1.number FROM table1 INNER JOIN table2 USING(id) INNER JOIN table3 USING(id) It returns an empty result, no errors
  3. thx for the quick reply! i tried using ur code but its not working like i wanted Heres a better example of what i want to get: Table1 id number 1 1234 2 4321 Table2 id username 1 random_username Table3 id password 2 random_password What if i want to display all the numbers from table1, where id from table1 matches id from table2 AND table3? if it was only 2 tables, this would work: SELECT number FROM Table1, Table2 WHERE Table1.ID = Table2.ID im getting always getthing this error - field list is ambiguous
  4. Got these tables: Table1 ID USER 1 User1 2 User2 Table2 ID CAR 1 Car1 2 Car2 Table3 ID STREET 1 Street1 2 Street2 If i wanned to display USER and CAR columns from Table1 and Table2, i would write: SELECT USER, CAR FROM Table1, Table2 WHERE Table1.ID = Table2.ID What if i wanned to add a third table (Table3), how does the code change? SELECT USER, CAR, STREET FROM Table1, Table2, Table3 WHERE ........
  5. I have main JFrame1, and it has some buttons on it. I know how to make it so JFrame1 would close and only JFrame2 would be visible, once i press a button. Can i open JFrame2 in the same window (JFrame1) by pressing a button? What tutorial do i need to search for this?
  6. made it work: private void whoslogedinLabel(){ try { String sql = "SELECT vardas_pavarde FROM Vartotojas WHERE login='" + whosloggedin + "'"; pst = conn.prepareStatement(sql); //pst.setString(1, whosloggedin); rs = pst.executeQuery(sql); while (rs.next()) { logininfoLabel.setText(rs.getString("vardas_pavarde")); } } catch (Exception e){ JOptionPane.showMessageDialog(null, e); } } thx guys
  7. no longer getting error, but instead of the Surname it just writes the string.. ("select Surname from Users where login = 'Admin'")
  8. Hey, i need to take just one element from my database table. I have this table - Users. and it has ID, Login, Password and Surname. I want to take just surname from this table. Something like ("Select Surname from Users where login =") Im trying to use this, but it gives me errors saying this ("Unkown column 'Admin' in 'where clause'"): private void whoslogedinLabel(){ String sql = "select Surname from Users where login = Admin"; try { pst = conn.prepareStatement(sql); rs = pst.executeQuery(); logininfoLabel.setText(sql); } catch (Exception e){ JOptionPane.showMessageDialog(null, e); } } logininfoLabel - is the label where i want the Surname to be displayed
  9. Hello, i have a problem fetching data from database, ill try explain what i need help with.. I got a login frame, that has login textfield, password textfield and a submit button. When i press the submit button, if the login and password was correct, it switches to new frame, the login frame disappears. In the new frame, i want to put a label, that would take 1 specific data field from the database. Something like this - "Select Surname from Users where Loginid = login". How do i take the login textfield data from login frame, and display it in the new frame? After i do this, can i create a new method in the new frame like this, and then just call it? (i took this from a tutorial where instead of updating a label, it updates the whole table) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void whoslogedinLabel(){ String sql = "select Surname from Users where Loginid = Login texfield"; try { pst = conn.prepareStatement(sql); rs = pst.executeQuery(); logininfoLabel.setText(sql); } catch (Exception e){ JOptionPane.showMessageDialog(null, e); } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// highlighted the red text where i think is the problem
  10. .. Cant edit my previous post, so making new one again..... Solved the jframe thingy with by making new method in the login JFrame: public void closeLogin() { WindowEvent winClosingEvent = new WindowEvent(this,WindowEvent.WINDOW_CLOSING); Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(winClosingEvent); } And then called this method after the login button is pressed: try { pst = conn.prepareStatement(sql); pst.setString(1, txtusername.getText()); pst.setString(2, txtpassword.getText()); rs = pst.executeQuery(); if (rs.next()){ closeLogin(); QueryJFrame s = new QueryJFrame(); s.setVisible(true); } Thx guys
  11. Hmm idk why i cant edit my earlier post twice, so making a new post now.. Ok so i managed to get what i want with the info message windows by just adding a new label field into the GUI and changing: This //JOptionPane.showMessageDialog(null, "Prisijungimo duomenys teisingi"); Into this logincheckLabel.setText("Prisijungimo duomenys teisingi"); Still cant find anything with the JFrame..
  12. Thx for helping, i have only 2 jframes now, ill post both of their codes because im not sure witch one is the main one This is the one that opens after succesfull login: public class QueryJFrame extends javax.swing.JFrame { public QueryJFrame() { initComponents(); } @SuppressWarnings("unchecked") private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 400, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 300, Short.MAX_VALUE) ); pack(); } public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new QueryJFrame().setVisible(true); } }); } } And this is the code from the login frame import java.sql.*; import javax.swing.*; public class loginJFrame extends javax.swing.JFrame { Connection conn = null; ResultSet rs = null; PreparedStatement pst = null; public loginJFrame() { initComponents(); } @SuppressWarnings("unchecked") private void formWindowOpened(java.awt.event.WindowEvent evt) { conn = mysqlconnect.ConnectDb(); } private void cmdloginMouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: String sql = "select * from Vartotojas where login = ? and password = ?"; try { pst = conn.prepareStatement(sql); pst.setString(1, txtusername.getText()); pst.setString(2, txtpassword.getText()); rs = pst.executeQuery(); if (rs.next()){ JOptionPane.showMessageDialog(null, "Prisijungimo duomenys teisingi"); QueryJFrame s = new QueryJFrame(); s.setVisible(true); } else JOptionPane.showMessageDialog(null, "Prisijungimo duomenys neteisingi"); } catch (Exception e){ JOptionPane.showMessageDialog(null, e); } } public static void main(String args[]) { try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(loginJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(loginJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(loginJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(loginJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new loginJFrame().setVisible(true); } }); } private javax.swing.JButton cmdlogin; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JPanel jPanel1; private javax.swing.JPasswordField txtpassword; private javax.swing.JTextField txtusername; } And this is connection to database file import java.sql.*; import javax.swing.*; public class mysqlconnect { Connection conn = null; public static Connection ConnectDb() { try{ Class.forName("com.mysql.jdbc.Driver"); Connection conn = DriverManager.getConnection("jdbc:mysql://database info"); JOptionPane.showMessageDialog(null, "Prisijungimas pavyko"); return conn; }catch (Exception e) { JOptionPane.showMessageDialog(null, e); return null; } } } This is my entire code, ill go look into that JPanel attachment to JFrame thing now.
  13. Hey, im using NetBeans to make a simple GUI, that would connect to a mysql database. I followed some guides and managed to make something, but now i want to change some features and i dont know what to look for on google/youtube.. Ill try to explain what i need, maybe someone can help me with it or point me in the right direction on what i should be looking for. So, when i press 'Run Project' in NetBeans, 1st i get this: 1) I would like to put that info message window, where it says that connection to database is established, somewhere in the GUI, is that possible? After i press 'OK' on the info message window, i can then input my login/password and login into the databse, heres the screen: 2) Here the info message window says that the login information is correct, again, i would like to hide this info window so that it would display somewhere in the GUI and not as a pop-up window. After i press 'OK' on the login detail window, a new 'JFrame' opens up (witch i will fill in with other things that i need later), heres the screen: 3) The old 'Login form' window didnt dissapear, can i make it so the new 'JFrame' opens up and the login frame dissapears, or can i make it so that the new JFrame window would replace the login frame? Heres the code just in case: Settings for database, shows the 1st info message window (if connection was succesfull): public class mysqlconnect { Connection conn = null; public static Connection ConnectDb() { try{ Class.forName("com.mysql.jdbc.Driver"); Connection conn = DriverManager.getConnection("jdbc:mysql://Database related stuff"); JOptionPane.showMessageDialog(null, "Prisijungimas pavyko"); return conn; }catch (Exception e) { JOptionPane.showMessageDialog(null, e); return null; } } } When i click the 'Login' button in the login frame, shows if login info was correct or not, also if correct opens new JFrame: private void cmdloginMouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: String sql = "select * from Vartotojas where login = ? and password = ?"; try { pst = conn.prepareStatement(sql); pst.setString(1, txtusername.getText()); pst.setString(2, txtpassword.getText()); rs = pst.executeQuery(); if (rs.next()){ JOptionPane.showMessageDialog(null, "Prisijungimo duomenys teisingi"); QueryJFrame s = new QueryJFrame(); s.setVisible(true); } else JOptionPane.showMessageDialog(null, "Prisijungimo duomenys neteisingi"); } catch (Exception e){ JOptionPane.showMessageDialog(null, e); } } So yeah, these are my main problems at the moment, i dont really know what to type into google for help, so hoping someone here will clear things for me.. Also got some side questions: 4) After im done with this project, can i make it so it would be installable program? 5) If i can install it, can i make it start-up automatically every time i turn on the computer? (for example, like any antivirus program or even skype) 6) If i can install it, can it have its own icon near the clock in the bottom right corner? Thx and sorry if this was posted in the wrong seciton.
  14. found an answer <input name="current_date" type="text" value="<?php echo date("Y-m-d"); ?>" readonly="readonly"/> writes currnet date to the text field, and when i press submit it writes it to the database..
  15. Got this code: <label>Current date :</label> <input name="current_date" type="date"/> if(isset($_POST['submitted'])){ $error = FALSE; if (empty($_POST['current_date'])) { $error [] = 1; } else { $current_date= $_POST['current_date']; } if (!$error) { $sqlinsert = "INSERT INTO Date (current_date) VALUES ('$current_date')"; mysql_query($sqlinsert); } else { } } How do i make it so it automatically isert current date into the database?
×
×
  • 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.