id uit tabel vergelijken met hidden field
Ik zit met het volgende probleem. Ik haal eerst uit de database een aantal waarden op. Drukt men op de knop read, dan zou je boven de tabel waar je eerst de diverse waarden ophaalt het resultaat moeten krijgen van het bericht ( pm dat je wilt zien dat iemand gestuurd heeft ).
Echter..hij doet niets. Heb diverse dingen geprobeerd, waarbij het me een keer lukt dat hij iets weer gaf echter dat was zo maar een id...niet degene die gelinked hoort te zijn aan de submit button.
Dus dacht ik, hidden field vergelijken met het id..mag ook niet baten
Lang verhaal zo, maar dan hoop ik dat het wat duidelijk is.
hierbij de code...
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?
if(isset($_POST['showpm'])){
//zoeken pm
$pmsql = "SELECT * FROM pm WHERE sendto='" .mysql_real_escape_string($name). "' AND id='".mysql_real_escape_string($_POST['pmid'])."' ";
$query = mysql_query($pmsql) or die(mysql_error());
$row = mysql_fetch_array($query);
echo"<table width='100%' class='table'><tr bgcolor=$color>
<td align=center class=head><div align='left'><b>From :</b> <a href=\"view_profile.php?name=". $row['sendby'] ."\" onFocus=\"if(this.blur)this.blur()\">".$row['sendby']."</a> | <b>Subject :</b> ".$row['subject']."</div></td>
</tr>
<tr bgcolor=$color>
<td align=center class=tablearea><div align='left'>";
$row['message'] = htmlentities($row['message']);
$row['message'] = nl2br($row['message']);
$row['message'] = smilie($row['message']);
$row['message'] = bbcodes($row['message']);
$row['message'] = stripslashes($row['message']);
echo $row['message'];
echo ' </div></td>
</tr>
</table>';
}// einde van bericht
//zoeken pm
?>
<table width="100%">
<tr>
<td colspan="7" class="sub"><center>Current message(s) available : </center></td>
</tr>
<tr>
<td colspan="2" width="5%"></td>
<td width="15%"><font color='#ffffff'><strong>Sent by :</strong></font></td>
<td width="20%"><font color='#ffffff'><strong>Subject :</strong></font></td>
<td width="20%"><font color='#ffffff'><strong>Received :</strong></font></td>
<td width="23%"><font color='#ffffff'><strong>Replied :</strong></font></td>
</tr>
<?php
require("_mailbox.php");
$presult = mysql_query("SELECT * FROM pm
WHERE sendto='".mysql_real_escape_string($name)."' and del='1' ORDER BY id DESC LIMIT $min,$amount") or die(mysql_error());
$check_nums = mysql_num_rows($presult);
if (!isset($_POST['Clean'])){
if ((mysql_num_rows($presult) == 0) and (!isset($_POST['clean']))){
echo "<font color='#ffffff'>You don't have any messages.</font>";
}
else if($check_nums != 0){
$g="0";
while($row = mysql_fetch_array($presult)){
if ($g == 0){ $color="#666666"; $g="2"; }
else if($g == 2){$color="#474747"; $g="0"; }
if($row['rep'] == 1){
echo
"<tr bgcolor=$color>
<td class=tablearea align=center><input type='hidden' name='pmid' id='".$row['id']."' value='".$row['id']."'></td>
<td class=tablearea align=center><input type='checkbox' name='id[$g]' value='".$row['id']."' onFocus=\"if(this.blur)this.blur()\"/></td>
<td class=tablearea><a href=\"view_profile.php?name=". $row['sendby'] ."\" onFocus=\"if(this.blur)this.blur()\">".$row['sendby']."</td>
<td class=tablearea><font color='#ffffff'><onclick=\"window.location='?page=message'\"><font color='#ffffff'>".$row['subject']."</font></a></td>
<td class=tablearea width=13%><font color='#ffffff'>".$row['time']."</font></td>
<td class=tablearea width=16%><b><font color='#cc0000'>No.</font></b></td>
<td class=tablearea width=16%><input name='showpm' type='button' class='button' id='".$row['id']."' onclick=\"window.location='?page=message'\" value='Read.'></td>
</tr>";
}else{
echo
"<tr bgcolor=$color>
<td class=tablearea align=center><input type='hidden' name='pmid' id='".$row['id']."' value='".$row['id']."'></td>
<td class=tablearea align=center><input type='checkbox' name='id[$g]' value='".$row['id']."' onFocus=\"if(this.blur)this.blur()\"/></td>
<td class=tablearea><a href=\"view_profile.php?name=". $row['sendby'] ."\" onFocus=\"if(this.blur)this.blur()\">".$row['sendby']."</a></td>
<td class=tablearea><font color='#ffffff'><a href='' onclick=\"window.location='?page=message'\"><font color='#ffffff'>".$row['subject']."</font></a></td>
<td class=tablearea width=13%><font color='#ffffff'>".$row['time']."</font></td>
<td class=tablearea width=16%><b><font color='#00FF00'>Yes.</font></b></td>
<td class=tablearea width=16%><input name='showpm' type='button' class='button' id='".$row['id']."' onclick=\"window.location='?page=message'\" value='Read.'></td>
</tr>";
}
}//einde while
}
}
?>
if(isset($_POST['showpm'])){
//zoeken pm
$pmsql = "SELECT * FROM pm WHERE sendto='" .mysql_real_escape_string($name). "' AND id='".mysql_real_escape_string($_POST['pmid'])."' ";
$query = mysql_query($pmsql) or die(mysql_error());
$row = mysql_fetch_array($query);
echo"<table width='100%' class='table'><tr bgcolor=$color>
<td align=center class=head><div align='left'><b>From :</b> <a href=\"view_profile.php?name=". $row['sendby'] ."\" onFocus=\"if(this.blur)this.blur()\">".$row['sendby']."</a> | <b>Subject :</b> ".$row['subject']."</div></td>
</tr>
<tr bgcolor=$color>
<td align=center class=tablearea><div align='left'>";
$row['message'] = htmlentities($row['message']);
$row['message'] = nl2br($row['message']);
$row['message'] = smilie($row['message']);
$row['message'] = bbcodes($row['message']);
$row['message'] = stripslashes($row['message']);
echo $row['message'];
echo ' </div></td>
</tr>
</table>';
}// einde van bericht
//zoeken pm
?>
<table width="100%">
<tr>
<td colspan="7" class="sub"><center>Current message(s) available : </center></td>
</tr>
<tr>
<td colspan="2" width="5%"></td>
<td width="15%"><font color='#ffffff'><strong>Sent by :</strong></font></td>
<td width="20%"><font color='#ffffff'><strong>Subject :</strong></font></td>
<td width="20%"><font color='#ffffff'><strong>Received :</strong></font></td>
<td width="23%"><font color='#ffffff'><strong>Replied :</strong></font></td>
</tr>
<?php
require("_mailbox.php");
$presult = mysql_query("SELECT * FROM pm
WHERE sendto='".mysql_real_escape_string($name)."' and del='1' ORDER BY id DESC LIMIT $min,$amount") or die(mysql_error());
$check_nums = mysql_num_rows($presult);
if (!isset($_POST['Clean'])){
if ((mysql_num_rows($presult) == 0) and (!isset($_POST['clean']))){
echo "<font color='#ffffff'>You don't have any messages.</font>";
}
else if($check_nums != 0){
$g="0";
while($row = mysql_fetch_array($presult)){
if ($g == 0){ $color="#666666"; $g="2"; }
else if($g == 2){$color="#474747"; $g="0"; }
if($row['rep'] == 1){
echo
"<tr bgcolor=$color>
<td class=tablearea align=center><input type='hidden' name='pmid' id='".$row['id']."' value='".$row['id']."'></td>
<td class=tablearea align=center><input type='checkbox' name='id[$g]' value='".$row['id']."' onFocus=\"if(this.blur)this.blur()\"/></td>
<td class=tablearea><a href=\"view_profile.php?name=". $row['sendby'] ."\" onFocus=\"if(this.blur)this.blur()\">".$row['sendby']."</td>
<td class=tablearea><font color='#ffffff'><onclick=\"window.location='?page=message'\"><font color='#ffffff'>".$row['subject']."</font></a></td>
<td class=tablearea width=13%><font color='#ffffff'>".$row['time']."</font></td>
<td class=tablearea width=16%><b><font color='#cc0000'>No.</font></b></td>
<td class=tablearea width=16%><input name='showpm' type='button' class='button' id='".$row['id']."' onclick=\"window.location='?page=message'\" value='Read.'></td>
</tr>";
}else{
echo
"<tr bgcolor=$color>
<td class=tablearea align=center><input type='hidden' name='pmid' id='".$row['id']."' value='".$row['id']."'></td>
<td class=tablearea align=center><input type='checkbox' name='id[$g]' value='".$row['id']."' onFocus=\"if(this.blur)this.blur()\"/></td>
<td class=tablearea><a href=\"view_profile.php?name=". $row['sendby'] ."\" onFocus=\"if(this.blur)this.blur()\">".$row['sendby']."</a></td>
<td class=tablearea><font color='#ffffff'><a href='' onclick=\"window.location='?page=message'\"><font color='#ffffff'>".$row['subject']."</font></a></td>
<td class=tablearea width=13%><font color='#ffffff'>".$row['time']."</font></td>
<td class=tablearea width=16%><b><font color='#00FF00'>Yes.</font></b></td>
<td class=tablearea width=16%><input name='showpm' type='button' class='button' id='".$row['id']."' onclick=\"window.location='?page=message'\" value='Read.'></td>
</tr>";
}
}//einde while
}
}
?>
error_reporting?
Naar mijn weten zit het in mijn query...maar ik zie het echt niet
Waar komt $name vandaan?
Dus die klopt.
Heb ook wat veranderd, alleen krijg nu van de 50 resultaten die hij weergeeft alleen de oudste van die 50.
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?
if(isset($_POST['showpm'])){
//zoeken pm
$pmsql = "SELECT * FROM pm WHERE sendto='" .mysql_real_escape_string($name). "' AND id='".mysql_real_escape_string($_POST['pmid'])."' ";
$query = mysql_query($pmsql) or die(mysql_error());
$row = mysql_fetch_array($query);
echo"<table width='100%' class='table'><tr bgcolor=$color>
<td align=center class=head><div align='left'><b>From :</b> <a href=\"view_profile.php?name=". $row['sendby'] ."\" onFocus=\"if(this.blur)this.blur()\">".$row['sendby']."</a> | <b>Subject :</b> ".$row['subject']."</div></td>
</tr>
<tr bgcolor=$color>
<td align=center class=tablearea><div align='left'>";
$row['message'] = htmlentities($row['message']);
$row['message'] = nl2br($row['message']);
$row['message'] = smilie($row['message']);
$row['message'] = bbcodes($row['message']);
$row['message'] = stripslashes($row['message']);
echo $row['message'];
echo ' </div></td>
</tr>
<tr><td>
';
echo "<a href=\"message.php?name=". $row['sendby'] ."&reply=". $row['id'] ."\" onFocus=\"if(this.blur)this.blur()\">Reply.</a>
</td>
</tr>
</table>";
}// einde van bericht
//zoeken pm
?>
<table width="100%">
<tr>
<td colspan="7" class="sub"><center>Current message(s) available : </center></td>
</tr>
<tr>
<td colspan="2" width="5%"></td>
<td width="15%"><font color='#ffffff'><strong>Sent by :</strong></font></td>
<td width="20%"><font color='#ffffff'><strong>Subject :</strong></font></td>
<td width="20%"><font color='#ffffff'><strong>Received :</strong></font></td>
<td width="23%"><font color='#ffffff'><strong>Replied :</strong></font></td>
</tr>
<?php
require("_mailbox.php");
$presult = mysql_query("SELECT * FROM pm
WHERE sendto='".mysql_real_escape_string($name)."' and del='1' ORDER BY id DESC LIMIT $min,$amount") or die(mysql_error());
$check_nums = mysql_num_rows($presult);
if (!isset($_POST['Clean'])){
if ((mysql_num_rows($presult) == 0) and (!isset($_POST['clean']))){
echo "<font color='#ffffff'>You don't have any messages.</font>";
}
else if($check_nums != 0){
$g="0";
while($row = mysql_fetch_array($presult)){
if ($g == 0){ $color="#666666"; $g="2"; }
else if($g == 2){$color="#474747"; $g="0"; }
if($row['rep'] == 1){
echo
"<tr bgcolor=$color>
<td class=tablearea align=center><input type='hidden' name='pmid' id='".$row['id']."' value='".$row['id']."'></td>
<td class=tablearea align=center><input type='checkbox' name='id[$g]' value='".$row['id']."' onFocus=\"if(this.blur)this.blur()\"/></td>
<td class=tablearea><a href=\"view_profile.php?name=". $row['sendby'] ."\" onFocus=\"if(this.blur)this.blur()\">".$row['sendby']."</td>
<td class=tablearea><font color='#ffffff'><onclick=\"window.location='?page=message'\"><font color='#ffffff'>".$row['subject']."</font></a></td>
<td class=tablearea width=13%><font color='#ffffff'>".$row['time']."</font></td>
<td class=tablearea width=16%><b><font color='#cc0000'>No.</font></b></td>
<td class=tablearea width=16%><input name='showpm' type='submit' class='button' id='showpm' value='Read.'></td>
</tr>";
}else{
echo
"<tr bgcolor=$color>
<td class=tablearea align=center><input type='hidden' name='pmid' id='".$row['id']."' value='".$row['id']."'></td>
<td class=tablearea align=center><input type='checkbox' name='id[$g]' value='".$row['id']."' onFocus=\"if(this.blur)this.blur()\"/></td>
<td class=tablearea><a href=\"view_profile.php?name=". $row['sendby'] ."\" onFocus=\"if(this.blur)this.blur()\">".$row['sendby']."</a></td>
<td class=tablearea><font color='#ffffff'><a href='' onclick=\"window.location='?page=message'\"><font color='#ffffff'>".$row['subject']."</font></a></td>
<td class=tablearea width=13%><font color='#ffffff'>".$row['time']."</font></td>
<td class=tablearea width=16%><b><font color='#00FF00'>Yes.</font></b></td>
<td class=tablearea width=16%><input name='showpm' type='submit' class='button' id='showpm' value='Read.'></td>
</tr>";
}
}//einde while
}
}
?>
</table>
if(isset($_POST['showpm'])){
//zoeken pm
$pmsql = "SELECT * FROM pm WHERE sendto='" .mysql_real_escape_string($name). "' AND id='".mysql_real_escape_string($_POST['pmid'])."' ";
$query = mysql_query($pmsql) or die(mysql_error());
$row = mysql_fetch_array($query);
echo"<table width='100%' class='table'><tr bgcolor=$color>
<td align=center class=head><div align='left'><b>From :</b> <a href=\"view_profile.php?name=". $row['sendby'] ."\" onFocus=\"if(this.blur)this.blur()\">".$row['sendby']."</a> | <b>Subject :</b> ".$row['subject']."</div></td>
</tr>
<tr bgcolor=$color>
<td align=center class=tablearea><div align='left'>";
$row['message'] = htmlentities($row['message']);
$row['message'] = nl2br($row['message']);
$row['message'] = smilie($row['message']);
$row['message'] = bbcodes($row['message']);
$row['message'] = stripslashes($row['message']);
echo $row['message'];
echo ' </div></td>
</tr>
<tr><td>
';
echo "<a href=\"message.php?name=". $row['sendby'] ."&reply=". $row['id'] ."\" onFocus=\"if(this.blur)this.blur()\">Reply.</a>
</td>
</tr>
</table>";
}// einde van bericht
//zoeken pm
?>
<table width="100%">
<tr>
<td colspan="7" class="sub"><center>Current message(s) available : </center></td>
</tr>
<tr>
<td colspan="2" width="5%"></td>
<td width="15%"><font color='#ffffff'><strong>Sent by :</strong></font></td>
<td width="20%"><font color='#ffffff'><strong>Subject :</strong></font></td>
<td width="20%"><font color='#ffffff'><strong>Received :</strong></font></td>
<td width="23%"><font color='#ffffff'><strong>Replied :</strong></font></td>
</tr>
<?php
require("_mailbox.php");
$presult = mysql_query("SELECT * FROM pm
WHERE sendto='".mysql_real_escape_string($name)."' and del='1' ORDER BY id DESC LIMIT $min,$amount") or die(mysql_error());
$check_nums = mysql_num_rows($presult);
if (!isset($_POST['Clean'])){
if ((mysql_num_rows($presult) == 0) and (!isset($_POST['clean']))){
echo "<font color='#ffffff'>You don't have any messages.</font>";
}
else if($check_nums != 0){
$g="0";
while($row = mysql_fetch_array($presult)){
if ($g == 0){ $color="#666666"; $g="2"; }
else if($g == 2){$color="#474747"; $g="0"; }
if($row['rep'] == 1){
echo
"<tr bgcolor=$color>
<td class=tablearea align=center><input type='hidden' name='pmid' id='".$row['id']."' value='".$row['id']."'></td>
<td class=tablearea align=center><input type='checkbox' name='id[$g]' value='".$row['id']."' onFocus=\"if(this.blur)this.blur()\"/></td>
<td class=tablearea><a href=\"view_profile.php?name=". $row['sendby'] ."\" onFocus=\"if(this.blur)this.blur()\">".$row['sendby']."</td>
<td class=tablearea><font color='#ffffff'><onclick=\"window.location='?page=message'\"><font color='#ffffff'>".$row['subject']."</font></a></td>
<td class=tablearea width=13%><font color='#ffffff'>".$row['time']."</font></td>
<td class=tablearea width=16%><b><font color='#cc0000'>No.</font></b></td>
<td class=tablearea width=16%><input name='showpm' type='submit' class='button' id='showpm' value='Read.'></td>
</tr>";
}else{
echo
"<tr bgcolor=$color>
<td class=tablearea align=center><input type='hidden' name='pmid' id='".$row['id']."' value='".$row['id']."'></td>
<td class=tablearea align=center><input type='checkbox' name='id[$g]' value='".$row['id']."' onFocus=\"if(this.blur)this.blur()\"/></td>
<td class=tablearea><a href=\"view_profile.php?name=". $row['sendby'] ."\" onFocus=\"if(this.blur)this.blur()\">".$row['sendby']."</a></td>
<td class=tablearea><font color='#ffffff'><a href='' onclick=\"window.location='?page=message'\"><font color='#ffffff'>".$row['subject']."</font></a></td>
<td class=tablearea width=13%><font color='#ffffff'>".$row['time']."</font></td>
<td class=tablearea width=16%><b><font color='#00FF00'>Yes.</font></b></td>
<td class=tablearea width=16%><input name='showpm' type='submit' class='button' id='showpm' value='Read.'></td>
</tr>";
}
}//einde while
}
}
?>
</table>
Post alleen relevante code met een duidelijke probleemomschrijving. Ik ga die lap code niet doorspitten terwijl ik eigenlijk niet weet waar ik naar moet kijken. En zo denken er meer mensen over.
Probleem naar mijn idee zit hier :
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
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
<?
if(isset($_POST['showpm'])){
//zoeken pm
$pmsql = "SELECT * FROM pm WHERE sendto='" .mysql_real_escape_string($name). "' AND id='".mysql_real_escape_string($_POST['pmid'])."' ";
$query = mysql_query($pmsql) or die(mysql_error());
$row = mysql_fetch_array($query);
echo"<table width='100%' class='table'><tr bgcolor=$color>
<td align=center class=head><div align='left'><b>From :</b> <a href=\"view_profile.php?name=". $row['sendby'] ."\" onFocus=\"if(this.blur)this.blur()\">".$row['sendby']."</a> | <b>Subject :</b> ".$row['subject']."</div></td>
</tr>
<tr bgcolor=$color>
<td align=center class=tablearea><div align='left'>";
$row['message'] = htmlentities($row['message']);
$row['message'] = nl2br($row['message']);
$row['message'] = smilie($row['message']);
$row['message'] = bbcodes($row['message']);
$row['message'] = stripslashes($row['message']);
echo $row['message'];
echo ' </div></td>
</tr>
<tr><td>
';
echo "<a href=\"message.php?name=". $row['sendby'] ."&reply=". $row['id'] ."\" onFocus=\"if(this.blur)this.blur()\">Reply.</a>
</td>
</tr>
</table>";
}// einde van bericht
?>
if(isset($_POST['showpm'])){
//zoeken pm
$pmsql = "SELECT * FROM pm WHERE sendto='" .mysql_real_escape_string($name). "' AND id='".mysql_real_escape_string($_POST['pmid'])."' ";
$query = mysql_query($pmsql) or die(mysql_error());
$row = mysql_fetch_array($query);
echo"<table width='100%' class='table'><tr bgcolor=$color>
<td align=center class=head><div align='left'><b>From :</b> <a href=\"view_profile.php?name=". $row['sendby'] ."\" onFocus=\"if(this.blur)this.blur()\">".$row['sendby']."</a> | <b>Subject :</b> ".$row['subject']."</div></td>
</tr>
<tr bgcolor=$color>
<td align=center class=tablearea><div align='left'>";
$row['message'] = htmlentities($row['message']);
$row['message'] = nl2br($row['message']);
$row['message'] = smilie($row['message']);
$row['message'] = bbcodes($row['message']);
$row['message'] = stripslashes($row['message']);
echo $row['message'];
echo ' </div></td>
</tr>
<tr><td>
';
echo "<a href=\"message.php?name=". $row['sendby'] ."&reply=". $row['id'] ."\" onFocus=\"if(this.blur)this.blur()\">Reply.</a>
</td>
</tr>
</table>";
}// einde van bericht
?>
Hij geeft 50 resultaten ( berichten ) weer per pagina. Als je dus op read klikt moet je het desbtreffende bericht dat erbij hoort te zien krijgen. Alleen ik krijg elke keer op elke pagina van die 50 resultaten alleen de oudste te zien. Op welke knop ik ook druk
Kijk eens in je bron wat voor id in de link getoond wordt.
SELECT .........AND id=.....