Gegevens worden niet uit db gehaald?
Kan iemand mij vertellen wat er fout gaat?
Hij zou de code moeten Loopen totdat hij alle data heeft gehad.
<head>
<title>© by djmagich</title>
</head>
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
28
29
30
31
32
33
34
35
36
37
38
39
40
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
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
include("includes/connect.inc.php");
if(!isset($query) || empty($query))
{
$query = "SELECT ObjectID, Foto1, Plaats, Vraagprijs from gegevens1";
}
$query=stripslashes($query);
$result = mssql_query($query);
$number_cols = mssql_num_fields($result);
echo "<center>\n";
echo "<table border = 0 width = 95%>\n";
echo "<tr align=left>\n";
for ($i=0; $i<$number_cols; $i++)
{
//echo "<th>" . mssql_field_name($result, $i). "</th>\n";
}
echo "</tr>\n";
while ($row = mssql_fetch_row($result))
for ($i=4; $i<$number_cols; $i++)
{
//echo "<td><img src='images/".$row['Foto1']."' width=100 height=75></td>";
}
{
echo "<td><a href=info.php?id=".$row['ObjectID'].">".$row['Adres']."</a></td>";
}
{
echo "<td>".$row['Plaats']."</td>";
}
{
echo "<td> € ".$row['Vraagprijs']." k.k.</td>";
}
echo "</tr>\n";
echo "</table>";
?>
include("includes/connect.inc.php");
if(!isset($query) || empty($query))
{
$query = "SELECT ObjectID, Foto1, Plaats, Vraagprijs from gegevens1";
}
$query=stripslashes($query);
$result = mssql_query($query);
$number_cols = mssql_num_fields($result);
echo "<center>\n";
echo "<table border = 0 width = 95%>\n";
echo "<tr align=left>\n";
for ($i=0; $i<$number_cols; $i++)
{
//echo "<th>" . mssql_field_name($result, $i). "</th>\n";
}
echo "</tr>\n";
while ($row = mssql_fetch_row($result))
for ($i=4; $i<$number_cols; $i++)
{
//echo "<td><img src='images/".$row['Foto1']."' width=100 height=75></td>";
}
{
echo "<td><a href=info.php?id=".$row['ObjectID'].">".$row['Adres']."</a></td>";
}
{
echo "<td>".$row['Plaats']."</td>";
}
{
echo "<td> € ".$row['Vraagprijs']." k.k.</td>";
}
echo "</tr>\n";
echo "</table>";
?>
Edit: En wat hebben de { en } voor nut in:
{
echo "<td> € ".$row['Vraagprijs']." k.k.</td>";
}
Gewijzigd op 27/09/2005 11:42:00 door - SanThe -
ja
$result = mssql_query($query) or die(mssql_error());
(Ik neem aan dat mssql_error() bestaande syntax is)
Krijg geen errors als ik die er bij zet.
Heb hier en daar wat aangepast, en krijg nu Undefined Index errors terwijl dat wat hij wil aanroepen wel gedefineerd is...
echo $number_cols;
Maar krijg dan die error op regel 28
echo "<td><img src='images/".$row['Foto1']."' width=100 height=75></td>";
de code is nu:
<head>
<title>© by djmagich</title>
</head>
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
28
29
30
31
32
33
34
35
36
37
38
39
40
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
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
include("includes/connect.inc.php");
if(!isset($query) || empty($query))
{
$query = "SELECT ObjectID, Foto1, Plaats, Vraagprijs from gegevens1";
}
$query=stripslashes($query);
$result = mssql_query($query) or die(mssql_error());
$number_cols = mssql_num_fields($result);
echo "<center>\n";
echo "<table border = 0 width = 95%>\n";
echo "<tr align=left>\n";
for ($i=0; $i<$number_cols; $i++)
{
echo "<th>" . mssql_field_name($result, $i). "</th>\n";
}
echo "</tr>\n";
while ($row = mssql_fetch_row($result))
for ($i=0; $i<$number_cols; $i++)
{
echo "<td><img src='images/".$row['Foto1']."' width=100 height=75></td>";
}
{
echo "<td><a href=info.php?id=".$row['ObjectID'].">".$row['Adres']."</a></td>";
}
{
echo "<td>".$row['Plaats']."</td>";
}
{
echo "<td> € ".$row['Vraagprijs']." k.k.</td>";
}
echo "</tr>\n";
echo "</table>";
?>
include("includes/connect.inc.php");
if(!isset($query) || empty($query))
{
$query = "SELECT ObjectID, Foto1, Plaats, Vraagprijs from gegevens1";
}
$query=stripslashes($query);
$result = mssql_query($query) or die(mssql_error());
$number_cols = mssql_num_fields($result);
echo "<center>\n";
echo "<table border = 0 width = 95%>\n";
echo "<tr align=left>\n";
for ($i=0; $i<$number_cols; $i++)
{
echo "<th>" . mssql_field_name($result, $i). "</th>\n";
}
echo "</tr>\n";
while ($row = mssql_fetch_row($result))
for ($i=0; $i<$number_cols; $i++)
{
echo "<td><img src='images/".$row['Foto1']."' width=100 height=75></td>";
}
{
echo "<td><a href=info.php?id=".$row['ObjectID'].">".$row['Adres']."</a></td>";
}
{
echo "<td>".$row['Plaats']."</td>";
}
{
echo "<td> € ".$row['Vraagprijs']." k.k.</td>";
}
echo "</tr>\n";
echo "</table>";
?>
Gewijzigd op 27/09/2005 12:02:00 door Harry
Is Foto1 wel exact hetzelfde geschreven als de tabelnaam?
Ja exact het zelfde...
SanThe:
Kijk eens hoeveel hier in zit:
echo $number_cols;
echo $number_cols;
Maar wat is hier het antwoord op?
Hoe bedoel je?
moet dat niet zijn
$number_cols = mssql_num_rows($result);
Nee volgens mij niet .
Zie code:
<head>
<title>© by djmagich</title>
</head>
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
28
29
30
31
32
33
34
35
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
28
29
30
31
32
33
34
35
<?php
include("includes/connect.inc.php");
if(!isset($query) || empty($query))
{
$query = "SELECT ObjectID,Foto1,Adres,Plaats,Vraagprijs from gegevens";
}
$query = stripslashes($query);
$result = mssql_query($query) or die(mssql_error());
$number_cols = mssql_num_fields($result);
echo "<center>\n";
echo "<table border = 0 width = 95%>\n";
echo "<tr align=left>\n";
for ($i=1; $i<$number_cols; $i++)
{
echo "<th>" . mssql_field_name($result, $i). "</th>\n";
}
echo "</tr>\n";
{
while ($row = mssql_fetch_row($result))
for ($i=1; $i<$number_cols; $i++)
echo "<tr>";
echo "<td><img src='images/". $row['Foto1']."' width=100 height=75></td>";
echo "<td><a href=info.php?id=".$row['ObjectID'].">".$row['Adres']."</a></td>";
echo "<td>".$row['Plaats']."</td>";
echo "<td> € ".$row['Vraagprijs']." k.k.</td>";
echo "</tr>\n";
echo "</table>";
}
?>
include("includes/connect.inc.php");
if(!isset($query) || empty($query))
{
$query = "SELECT ObjectID,Foto1,Adres,Plaats,Vraagprijs from gegevens";
}
$query = stripslashes($query);
$result = mssql_query($query) or die(mssql_error());
$number_cols = mssql_num_fields($result);
echo "<center>\n";
echo "<table border = 0 width = 95%>\n";
echo "<tr align=left>\n";
for ($i=1; $i<$number_cols; $i++)
{
echo "<th>" . mssql_field_name($result, $i). "</th>\n";
}
echo "</tr>\n";
{
while ($row = mssql_fetch_row($result))
for ($i=1; $i<$number_cols; $i++)
echo "<tr>";
echo "<td><img src='images/". $row['Foto1']."' width=100 height=75></td>";
echo "<td><a href=info.php?id=".$row['ObjectID'].">".$row['Adres']."</a></td>";
echo "<td>".$row['Plaats']."</td>";
echo "<td> € ".$row['Vraagprijs']." k.k.</td>";
echo "</tr>\n";
echo "</table>";
}
?>
for ($i=1; $i<$number_cols; $i++)
Waar is die for() voor?
En een while() heeft een begin { een een eind } tag.
Zo ook een for().
Dit snap ik niet:
for ($i=1; $i<$number_cols; $i++)
{
echo "<th>" . mssql_field_name($result, $i). "</th>\n";
}
En de while lijkt me meer zo:
while ($row = mssql_fetch_row($result))
{
echo "<tr>";
echo "<td><img src='images/". $row['Foto1']."' width=100 height=75></td>";
echo "<td><a href=info.php?id=".$row['ObjectID'].">".$row['Adres']."</a></td>";
echo "<td>".$row['Plaats']."</td>";
echo "<td> € ".$row['Vraagprijs']." k.k.</td>";
echo "</tr>\n";
}
Alleen nu zit ik dus nog met de connectie met de database omdat hij hier de velden niet herkent...
De code is nu als volgt:
<head>
<title>© by djmagich</title>
</head>
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
include("includes/connect.inc.php");
if(!isset($query) || empty($query))
{
$query = "SELECT ObjectID,Foto1,Adres,Plaats,Vraagprijs from gegevens1";
}
$query = stripslashes($query);
$result = mssql_query($query) or die(mssql_error());
$number_cols = mssql_num_fields($result);
echo "<center>\n";
echo "<table border = 0 width = 95%>\n";
echo "<tr align=left>\n";
while ($row = mssql_fetch_row($result))
{
echo "<tr>";
echo "<td><img src='images/". $row['Foto1']."' width=100 height=75></td>";
echo "<td><a href=info.php?id=".$row['ObjectID'].">".$row['Adres']."</a></td>";
echo "<td>".$row['Plaats']."</td>";
echo "<td> € ".$row['Vraagprijs']." k.k.</td>";
echo "</tr>\n";
}
?>
include("includes/connect.inc.php");
if(!isset($query) || empty($query))
{
$query = "SELECT ObjectID,Foto1,Adres,Plaats,Vraagprijs from gegevens1";
}
$query = stripslashes($query);
$result = mssql_query($query) or die(mssql_error());
$number_cols = mssql_num_fields($result);
echo "<center>\n";
echo "<table border = 0 width = 95%>\n";
echo "<tr align=left>\n";
while ($row = mssql_fetch_row($result))
{
echo "<tr>";
echo "<td><img src='images/". $row['Foto1']."' width=100 height=75></td>";
echo "<td><a href=info.php?id=".$row['ObjectID'].">".$row['Adres']."</a></td>";
echo "<td>".$row['Plaats']."</td>";
echo "<td> € ".$row['Vraagprijs']." k.k.</td>";
echo "</tr>\n";
}
?>
Enig idee hoe het kan?
De code is nu:
<head>
<title>© by djmagich</title>
</head>
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
include("includes/connect.inc.php");
if(!isset($query) || empty($query))
{
$query = "SELECT ObjectID,Foto1,Adres,Plaats,Vraagprijs from gegevens1";
}
$query = stripslashes($query);
$result = mssql_query($query) or die(mssql_error());
$number_cols = mssql_num_fields($result);
echo "<center>\n";
echo "<table border = 0 width = 95%>\n";
echo "<tr align=left>\n";
while ($row = mssql_fetch_row($result))
{
echo "<tr>";
echo "<td><img src='images/". $row['1']."' width=100 height=75></td>";
echo "<td><a href=info.php?id=".$row['0'].">".$row['2']."</a></td>";
echo "<td>".$row['3']."</td>";
echo "<td> € ".$row['4']." k.k.</td>";
echo "</tr>\n";
}
?>
include("includes/connect.inc.php");
if(!isset($query) || empty($query))
{
$query = "SELECT ObjectID,Foto1,Adres,Plaats,Vraagprijs from gegevens1";
}
$query = stripslashes($query);
$result = mssql_query($query) or die(mssql_error());
$number_cols = mssql_num_fields($result);
echo "<center>\n";
echo "<table border = 0 width = 95%>\n";
echo "<tr align=left>\n";
while ($row = mssql_fetch_row($result))
{
echo "<tr>";
echo "<td><img src='images/". $row['1']."' width=100 height=75></td>";
echo "<td><a href=info.php?id=".$row['0'].">".$row['2']."</a></td>";
echo "<td>".$row['3']."</td>";
echo "<td> € ".$row['4']." k.k.</td>";
echo "</tr>\n";
}
?>
Gewijzigd op 27/09/2005 13:53:00 door - SanThe -
Als ik fetch_array doe lukt het wel, dus conclusie --> Als je rows doet gaat ie nummeren en kijkt ie niet naar de namen...
Dus nou werkt alles?