Cerys Posted March 2, 2009 Share Posted March 2, 2009 Hi! What I'd like is for a link ('move on') to change the LIMIT value by one, so that the page displays the next word from the table. All of the data has an id number attatched to it (the table contains 'english', 'german', 'hint', 'id') - would it be simpler to limit it with that instead of the LIMIT? If so, how? Here's my current code: <html> <head> <title>German</title> <link rel="stylesheet" type="text/css" href="css.css"> </head> </body> <div id="card1"> <?php /* Connecting to MySQL */ $link = mysql_connect("localhost", "admin4413", "christine") or die("Could not connect : " . mysql_error()); $DB = "dvelopphotography_com_lang"; mysql_select_db($DB) or die ("Database $DB not select.." . mysql_error()); $table = "german"; mysql_select_db($DB) or die ("Database $DB not select.." . mysql_error()); if ($_GET['english']=='on'){ $result = mysql_query( "SELECT English FROM $table LIMIT 0,1"); while ( $pr_row = mysql_fetch_row( $result ) ) { print ""; foreach ( $pr_row as $data ) print "\t $data"; print "\n"; } print "\n"; mysql_close ( $link ); } if ($_GET['hint']=='on'){ $result = mysql_query( "SELECT hint FROM $table LIMIT 0,1"); $total_rows = mysql_num_rows( $result ); while ( $pr_row = mysql_fetch_row( $result ) ) { print ""; foreach ( $pr_row as $data ) print "\t $data"; print "\n"; } print "\n"; mysql_close ( $link ); } if ($_GET['answer']=='on'){ $result = mysql_query( "SELECT german FROM $table LIMIT 0,1"); $total_rows = mysql_num_rows( $result ); while ( $pr_row = mysql_fetch_row( $result ) ) { print ""; foreach ( $pr_row as $data ) print "\t $data"; print "\n"; } print "\n"; mysql_close ( $link ); }?> </div> <div id="link"> <p> <a href="?english=on">English</a> <br> <a href="?hint=on">Hint</a> <br> <a href="?answer=on">Answer</a> <p> <a href="?answer=off">Move On</a> </ p> <p><?php if($_GET['english'] == 'on') { echo 'this is in English'; } if($_GET['hint'] == 'on') { echo 'this is a hint'; } if($_GET['answer'] == 'on') { echo 'this is in German'; } ?></p> </div> <body> </html> Quote Link to comment Share on other sites More sharing options...
RussellReal Posted March 2, 2009 Share Posted March 2, 2009 simplest way is to go by id, but if you want to use limit, just set up a get variable like q assuming this is a quiz type game for German learners.. so like q=1 for question 1 german.php?q=1 then during the script when sum1 answers, just move them onto german.php?q=1 and then in the query do: "SELECT * FROM `german` As a, `english` As b, `hint` As c WHERE a.id = b.id AND b.id = c.id AND a.id = {$_GET['q']}" Quote Link to comment Share on other sites More sharing options...
RussellReal Posted March 2, 2009 Share Posted March 2, 2009 oo sryyy!! lol! I gave you the way to do it by ID I will give you the way to do it via LIMIT "SELECT * FROM `english` ORDER BY `id` ASC LIMIT {$_GET['q']},1" Quote Link to comment Share on other sites More sharing options...
Cerys Posted March 2, 2009 Author Share Posted March 2, 2009 Ok, I mostly see what you're saying... Can we pretend that I've been learning php for about 24 hours now, so would you show me how/where I would fit that in? Thanks! Quote Link to comment Share on other sites More sharing options...
RussellReal Posted March 2, 2009 Share Posted March 2, 2009 lol, if it were me doing that script I'd hafta redo it.. =\ Quote Link to comment Share on other sites More sharing options...
Cerys Posted March 2, 2009 Author Share Posted March 2, 2009 Oooh, that's so close to being the last thing I wanted to hear lol Which way would be simpler: a) doing it with LIMIT; or b) doing it by id number? Anyone? Failing that, can someone please point me to the "I have only a vague idea of waht I'm doing, someone help me before I die" forum? Quote Link to comment Share on other sites More sharing options...
RussellReal Posted March 2, 2009 Share Posted March 2, 2009 lol, use the LIMIT add me to MSN RussellonMSN@hotmail.com Quote Link to comment 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.