Jump to content

calle08

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

calle08's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I want to copy all the lines from 2011-09-01 and change the date to ex, 2011-09-02 i need to use the insert into line to make it work. But it may not work att all like this? Someone know what i can do to make it work? $laggtill = "insert into narvaro_3manna (fornamn, efternamn, narvaro_id, datum) SELECT fornamn, efternamn, narvaro_id, (datum) VALUES ('$datum') WHERE datum = '2011-09-01'";
  2. Yes all records for that date from some table into narvaro_3manna
  3. I want this question in the form. 2011-09-02 is the date that is added from the form. insert into narvaro_3manna (fornamn, efternamn, narvaro_id, datum) SELECT fornamn, efternamn, narvaro_id, '2011-09-02' FROM narvaro_3manna WHERE datum ='2011-09-01' Here is the line where i want the question. But getting syntax errors. $laggtill = "insert into narvaro_3manna (fornamn, efternamn, narvaro_id, datum) SELECT fornamn, efternamn, narvaro_id, (datum) VALUES ('$datum') WHERE datum = '2011-09-01'"; You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2011-09-02')' WHERE datum = '2011-09-01'' at line 1
  4. Using this form to add dates to my database. Getting error on line 14. Don't know the right syntax somone can help me get it to work? This line in the form don,t work. Posted all the form code under... $laggtill = "insert into narvaro_3manna (fornamn, efternamn, narvaro_id, datum) SELECT fornamn, efternamn, narvaro_id, (datum) VALUES ('$datum') WHERE datum = '2011-09-01'"; <code> <?php include "anslut.php"; // Databasanslutningen //Här uppdaterar tid IF($_GET['do']=='sparatid' && $_POST['datum']!=''){ $info=$_POST['info']; $uppdatera = "UPDATE narvaro_3manna SET info = '{$info}' WHERE datum = '{$datum}'"; $res = mysql_query($uppdatera) or die("SQL: Gick ej att uppdatera informationen $uppdatera <br>".mysql_error()); } //Här sparas nya ElseIF($_GET['do']=='nytid'){ $datum=$_POST['datum']; $laggtill = "insert into narvaro_3manna (fornamn, efternamn, narvaro_id, datum) SELECT fornamn, efternamn, narvaro_id, (datum) VALUES ('$datum') WHERE datum = '2011-09-01'"; $res = mysql_query($laggtill) or die('SQL: Gick ej att lägga till informationen $laggtill <br>'.mysql_error()); } //Här raderas tid ElseIF($_GET['do']=='raderatid' && $_GET['datum']!=''){ $datum=$_GET['datum']; $radera = "DELETE FROM narvaro_3manna WHERE datum = '$datum'"; mysql_query($radera) or die('SQL: Gick ej att radera informationen: $radera <br>'.mysql_error()); } //Här visas narvaro_3mannaa tid $sql = "SELECT DISTINCT datum, color, info FROM narvaro_3manna WHERE datum >= CURDATE( ) ORDER BY datum ASC"; $resultat = mysql_query($sql); echo "<table border ='0'>\n"; echo " <tr>\n"; echo " </tr>\n"; echo " <tr><form method='POST' action='?do=nytid'>\n"; echo " <td><input type='text' name='datum' size='10'></td>\n"; echo " <td><input type='submit' value='Spara nya' name='submitny'></td>\n"; echo " </form></tr>\n"; while($kolumn = mysql_fetch_array($resultat)){ echo " <tr><form method='POST' action='?do=sparatid'>\n"; echo " <input type='hidden' name='datum' value='{$kolumn['datum']}'>\n"; echo ' <td>'.$kolumn['datum'].'</td>'; echo " <td><input type='text' name='info' size='150' value='{$kolumn['info']}'>"; echo " <td><input type='submit' value='Spara' name='submit{$kolumn['datum']}'>"; echo " <a href='?do=raderatid&datum={$kolumn['datum']}'>Radera</a></td>\n"; echo " </form></tr>\n"; } echo "</table>\n"; ?> </code>
  5. How do i make a php form that do this sql question? One field to insert a new date. And one submit button. Don,t know how to start can somone help? insert into all (firstname, lastname, date, info) SELECT firstname, lastname, '2011-09-10', info FROM all WHERE date = '2011-08-30'
  6. I want to crate duplicates of the following but cnage the date to 2011-09-10 how can i do that? SELECT firstname, lastname, date, info FROM all WHERE date '2011-08-30'
  7. In the pic the i want only the two highlighted lins...
  8. can someone help me with that?
  9. Ok this olmost did it. Look at pic. How do i remove the Duplicates? The highlighted lins is the ones i want. [attachment deleted by admin]
  10. How to get started? I have been thinking that self-join can work. Looking at the manul but dont get it. How to get the date and comments from 2011-07-20 to join on 2011-17-14? Somone good at join can help?
  11. I need the result to list one row/name there is one field for every date in the database for user test1 there is two fields but i want to make it to one field and have both dates and comments in that one field. Get it to look like this test1 test1 2011-07-14 yes 2011-07-20 No test2 test2 2011-07-14 yes 2011-07-20 No I think i need it to be like thig for using while($kolumn = mysql_fetch_array($result)){ to make tables that works. It is hard for me to explain to SELECT name, date, commentFROM narvaro_allWHERE date BETWEEN '2011-07-14' AND '2011-07-20' If i use that question i get two fields/name i need one.
  12. That give same result as in ex1 in my picture = wrong. I must get it to look like ex2. I think its harder need somting like join or so?
  13. Thats the problem i always get the result as the first example in picture ex1. Thats wrong i want it to look like ex2. It is a script that tell if you can come or not. To print it on a web page i need it to look like ex2 is it possible? [attachment deleted by admin]
  14. Ok so how can i fix it? Use JOIN? I want the comments from 2011-07-20 to join after the comments from 2011-07-14 just don,t know what i can use? SELECT name, date, comment FROM narvaro_all WHERE date='2011-07-14'
  15. Wrong of me SELECT name, date, comment FROM narvaro_all WHERE date='2011-07-14' AND date='2011-07-20' But still get empty results. Don't understand?
×
×
  • 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.