Teller probleem
Dit is mn database:
Code (php)
1
2
3
4
5
6
7
2
3
4
5
6
7
CREATE TABLE tutorials (
id int(5) DEFAULT '0' NOT NULL auto_increment,
FileName varchar(50) NOT NULL,
FileURL varchar(255) NOT NULL,
Count smallint(5) NOT NULL,
PRIMARY KEY (id)
);
id int(5) DEFAULT '0' NOT NULL auto_increment,
FileName varchar(50) NOT NULL,
FileURL varchar(255) NOT NULL,
Count smallint(5) NOT NULL,
PRIMARY KEY (id)
);
Dit is view.php
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?
include "connect.php";
$x ="SELECT * from tutorials order by FileName";
$result = mysql_query($x) or die
("Could not execute query : $x." . mysql_error());
echo "<p align=center><b>File Download</b></p>";
while ($row=mysql_fetch_array($result))
{
$id = $row["id"];
$FileName = $row["FileName"];
$FileURL = $row["FileURL"];
$Count =$row["Count"];
echo "<a href=download.php?id=$id target=blank>$FileName</a></br>";
}
echo "visited: $Count";
?>
include "connect.php";
$x ="SELECT * from tutorials order by FileName";
$result = mysql_query($x) or die
("Could not execute query : $x." . mysql_error());
echo "<p align=center><b>File Download</b></p>";
while ($row=mysql_fetch_array($result))
{
$id = $row["id"];
$FileName = $row["FileName"];
$FileURL = $row["FileURL"];
$Count =$row["Count"];
echo "<a href=download.php?id=$id target=blank>$FileName</a></br>";
}
echo "visited: $Count";
?>
en dit is download.php
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
include "connect.php";
$x ="SELECT * from tutorials where id='$id'";
$result = mysql_query($x) or die
("Could not execute query : $x." . mysql_error());
while ($row = mysql_fetch_array($result))
{
$id = $row["id"];
$FileName = $row["FileName"];
$FileURL = $row["FileURL"];
$Count = $row["Count"];
header('Location: '.$FileURL);
$x ="update tutorials set Count=Count+1 where id='$id'";
$result = mysql_query($x) or die
("Could not execute query : $x." . mysql_error());
}
?>
include "connect.php";
$x ="SELECT * from tutorials where id='$id'";
$result = mysql_query($x) or die
("Could not execute query : $x." . mysql_error());
while ($row = mysql_fetch_array($result))
{
$id = $row["id"];
$FileName = $row["FileName"];
$FileURL = $row["FileURL"];
$Count = $row["Count"];
header('Location: '.$FileURL);
$x ="update tutorials set Count=Count+1 where id='$id'";
$result = mysql_query($x) or die
("Could not execute query : $x." . mysql_error());
}
?>
nou is het probleem dat de link niet verwijst naar de in de database genoemte link ...
http://test.scratch-design.nl/view.php is de link
alvast bedankt
Gewijzigd op 27/05/2005 12:10:00 door Kars
De
$id $filename $fileurl en $count, kijken of je uberhaupt iets terugkrijgt
*ik zou je connectiebestand even anders zetten daar, onverlaten kunnen er zo bij
hij echot de FileURL idd niet :S
en ik heb ondertussen ook gevonden waarom. Bedankt wes! wat in het script FileURL heet, hete in de db FileUrl... en daar had ik totaal overheen gekeken. (k ben niet voor niks newbie he :P)
bedankt ;)
Gewijzigd op 27/05/2005 12:49:00 door Kars
Ja ik dus ook haha...
(voor de anderen): ik had al gekeken voor hem
Is het ondertussen wel al gelukt?
Edit:
maar nadat ik een aantal aanpassingen had gedaan doet de helft het niet meer... :S
view.php
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?
include "connect.php";
$x ="SELECT * from tutorials order by id";
$result = mysql_query($x) or die
("Could not execute query : $x." . mysql_error());
while ($row=mysql_fetch_array($result))
{
$id = $row["id"];
$filename = $row["$filename"];
$pic = $row["pic"];
$author = $row["author"];
$descrip = $row["descrip"];
$Count = $row["Count"];
$url = $row["url"];
echo "<p align=center>$filename<br>";
echo "<img src=$pic ><br>
Author: $author<br>
$descrip<br>
Visited: $Count<br>
<a href=$url target=blank>View</a><br></p>";
}
?>
include "connect.php";
$x ="SELECT * from tutorials order by id";
$result = mysql_query($x) or die
("Could not execute query : $x." . mysql_error());
while ($row=mysql_fetch_array($result))
{
$id = $row["id"];
$filename = $row["$filename"];
$pic = $row["pic"];
$author = $row["author"];
$descrip = $row["descrip"];
$Count = $row["Count"];
$url = $row["url"];
echo "<p align=center>$filename<br>";
echo "<img src=$pic ><br>
Author: $author<br>
$descrip<br>
Visited: $Count<br>
<a href=$url target=blank>View</a><br></p>";
}
?>
download.php
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
include "connect.php";
$x ="SELECT * from tutorials where id='$id'";
$result = mysql_query($x) or die
("Could not execute query : $x." . mysql_error());
while ($row=mysql_fetch_object($result))
{
$id = "$row->id";
$filename = "$row->$filename";
$pic = "$row->pic";
$author = "$row->author";
$descrip = "$row->descrip";
$Count = "$row->Count";
$url = "$row->url";
echo "<script> self.location(\"$url\");</script>";
$x ="update tutorials set Count=Count+1 where id='$id'";
$result = mysql_query($x) or die
("Could not execute query : $x." . mysql_error());
}
?>
include "connect.php";
$x ="SELECT * from tutorials where id='$id'";
$result = mysql_query($x) or die
("Could not execute query : $x." . mysql_error());
while ($row=mysql_fetch_object($result))
{
$id = "$row->id";
$filename = "$row->$filename";
$pic = "$row->pic";
$author = "$row->author";
$descrip = "$row->descrip";
$Count = "$row->Count";
$url = "$row->url";
echo "<script> self.location(\"$url\");</script>";
$x ="update tutorials set Count=Count+1 where id='$id'";
$result = mysql_query($x) or die
("Could not execute query : $x." . mysql_error());
}
?>
de filename wil niet verschijnen (maar dit keer ligt het niet aan hoofdletters :P)
en de count werkt niet meer (hij laat nog wel het getal zien :S)
Gewijzigd op 27/05/2005 16:34:00 door Kars
(jah... edit was niet t handigste..)