Input [html] - tonen laatste xxx invoer

Status
Niet open voor verdere reacties.

sunadumari

Nieuwe gebruiker
Lid geworden
14 mrt 2008
Berichten
4
Hallo,

ik zoek een php script wat de laatste xxx aantal invoer toont.

Bijvoorbeeld:

een bezoeker heeft de mogelijkheid z'n voornaam en achternaam in te voeren middels de html-input code.
Daaronder staat dan een lijst met andere reeds ingevoerde voor- en achternamen door andere bezoekers (laatst gezocht).
 
Heb je die namen in een database staan?

Zo ja dan kun je met LIMIT wel uit de voeten.


The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be non-negative integer constants (except when using prepared statements).

With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):
SELECT * FROM tbl LIMIT 5,10; # Retrieve rows 6-15
To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the second parameter. This statement retrieves all rows from the 96th row to the last:
SELECT * FROM tbl LIMIT 95,18446744073709551615;
With one argument, the value specifies the number of rows to return from the beginning of the result set:
SELECT * FROM tbl LIMIT 5; # Retrieve first 5 rows
 
nee, ik heb nog helemaal niks. Ik begin van nul af aan... ik zoek dus een php (of andere?) script waarmee ik de ingevoerde voornaam+achternaam weer op een website kan toveren.
En dat van diverse bezoekers. Zo kunnen bezoekers zien wat er aan voor- en achternaam is ingevoerd...
 
Simpele database

nid INT(11) auto_increment Primary Key
naam VARCHAR(50)
type CHAR(1)
gezocht INT(11)

Stel voornaam is type 0, achternaam type 1

Voert iemand de naam Jan Patat in dan voer je 2x een INSERT-query uit.
De eerste voor de voornaam:
PHP:
"INSERT INTO namen
(naam, type, gezocht)
VALUES (
'". $_POST['voornaam'] ."',
'0',
'1')"
en voor de achternaam
PHP:
"INSERT INTO namen
(naam, type, gezocht)
VALUES (
'". $_POST['achternaam'] ."',
'1',
'1')"

Uiteraard kijk je voor je INSERT eerst of de voornaam of achternaam al bestaat. Zo ja dan doe je alleen gezocht +1
 
Status
Niet open voor verdere reacties.
Steun Ons

Nieuwste berichten

Terug
Bovenaan Onderaan