Jump to content

Recommended Posts

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>

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']}"

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?  :D

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.