php vraag

Gestart doorDesire24 reacties167 weergaven

25 berichten · pagina 2 van 2

Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Kyron schreef:
Ga anders php leren, zonder ga je het niet redden met je eigen site... er zal maar iets veranderd moeten worden en dan moet je mensen gaan mailen...
ik ben al aan het leren maar moest deze code echt super snel hebbenwink
Eleky schreef:
Astu

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>URL Shortener</title>
<link href="./style.css" rel="stylesheet" type="text/css"></link>
</head>
<body>
[COLOR= #0000BB]<?php[/COLOR]  

  [URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"connect.php"[/COLOR][COLOR= #007700]);[/COLOR]

 [COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT id, code, url, date FROM `url` ORDER BY `id` DESC "[/COLOR][COLOR= #007700];[/COLOR]
 [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR]mysqk_error[COLOR= #007700]());[/COLOR]
 [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]){[/COLOR]
  [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<i>Er zijn nog geen links verkort</i>"[/COLOR][COLOR= #007700];
 }[/COLOR]
 [URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
  [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])) {[/COLOR]
   [COLOR= #0000BB]$id[/COLOR] [COLOR= #007700]=[/COLOR] htmlspecialchars[COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]]);[/COLOR]
   [COLOR= #0000BB]$code[/COLOR] [COLOR= #007700]=[/COLOR] htmlspecialchars[COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]code[/COLOR][COLOR= #007700]]);[/COLOR]
   [COLOR= #0000BB]$url[/COLOR] [COLOR= #007700]=[/COLOR] htmlspecialchars[COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]url[/COLOR][COLOR= #007700]]);[/COLOR]
   [COLOR= #0000BB]$date[/COLOR] [COLOR= #007700]=[/COLOR] htmlspecialchars[COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]date[/COLOR][COLOR= #007700]]);[/COLOR]

   [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$id[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"<br />n"[/COLOR][COLOR= #007700];[/COLOR]
   [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$code[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"</br>n"[/COLOR][COLOR= #007700];[/COLOR]
   [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$date[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]" n"[/COLOR][COLOR= #007700];[/COLOR]
   [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"$url"[/COLOR][COLOR= #007700];
  }
 }[/COLOR]
?>

</body>
</html>
Bedankt eleky, de punten krijg je vandaag als ik ze binnen heb
0
Berichten
5.897
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
misschien zit er fout in databasetabel
0
Berichten
2.692
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Maartenl schreef:
misschien zit er fout in databasetabel
Het is al opgelost hea slimmerik emo
0
Berichten
1.579
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
$query = mysql_query($sql) or die(mysqk_error());

Moet dat niet
$query = mysql_query($sql) or die(mysql_error());

zijn?
0
Berichten
3.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik bedoel, je haalt net niet uit PHPAdmin, dat is slechts een PHP Administratie (nee echt ) tool die je database visualiseert.
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
het is opgelost alleen zit nu nog met 1 vraag,

screen:
Afbeelding

nu wil ik graag dat links, die ID`s 1 word, dus dat als er een url word verkort dat die ID dn 1 hoger word.

php code:

[COLOR= #0000BB]<?php[/COLOR]  

  [URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"connect.php"[/COLOR][COLOR= #007700]);[/COLOR]

 [COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT id, code, url, date FROM `items` ORDER BY `id` DESC "[/COLOR][COLOR= #007700];[/COLOR]
 [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
 [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]){[/COLOR]
  [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<i>Er zijn nog geen links verkort</i>"[/COLOR][COLOR= #007700];
 }[/COLOR]
 [URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
  [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])) {[/COLOR]
   [COLOR= #0000BB]$id[/COLOR] [COLOR= #007700]=[/COLOR] htmlspecialchars[COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]]);[/COLOR]

   [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$id[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"<br />n"[/COLOR][COLOR= #007700];
  }
 }[/COLOR]
?>
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
kan iemand me helpen met de post hierboven? please heb haast
0
Berichten
3.788
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je moet, in de database, id primary key maken, dan doet hij dat automatisch!
0
Berichten
832
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Gewoon het veld met ID zo doen: INT indexyummierimary en a/i aangekruisd
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Eleky schreef:
Je moet, in de database, id primary key maken, dan doet hij dat automatisch!
werkt nog niet
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren