if en else...

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Dennis

Dennis

30/10/2008 17:48:00
Quote Anchor link
Hallo,

Ik heb hieronder een script waarbij het de bedoeling is dat als er in een rij in de kolom hidename yes staat, er Anonymous ge-echod word. Echter, dat doet die dus ook..alleen bij alle veilingen in dit geval op mijn site ( online spel ).

Het hele script heb ik hieronder staan, het gaat dan om rij 44 en 111 waar ik dit heb staan :

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<? if ( $hidename == 'yes' ) { echo "Anonymous"; }else{echo"<a href=\"view_profile.php?name=". $row['seller']."\" onFocus=\"if(this.blur)this.blur()\">".$row['seller']."</a>";} ?>


Ik hoop dat iemand mij op weg kan helpen. Alvast bedankt!

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<? $pagename = "Quick Trade.";
require("top.php"); ?>

<?
require("usercheck.php");
require("prison_check.php");
require("locationcheck.php");
?>

<?php require("_auction.php"); ?>

<form method="post">
    <p>
        <input name="button" type="button" class="button" id="button" onclick="window.location='?page=points'"        value="Points.">
        <input name="button" type="button" class="button" id="button" onclick="window.location='?page=properties'"        value="Properties.">
    </p>
    <?
// Start of Points Page.
if( ( $_GET['page'] == "points" ) or ( empty( $_GET['page'] ) ) ) {
?>

    <table width="100%" border="0" align="center" cellspacing="0" class="table">
        <tr>
            <td valign="top"><table width="100%" align="center" cellspacing="5" class="table">
                    <tr>
                        <td align="left" class="sub"><b>Point Sales</b>: </td>
                    </tr>
                    <tr>
                        <td align="left" class="cell" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="2" class="table">
                                <tr>
                                    <td width="10%" align="left" class="cell"></td>
                                    <td width="20%" align="left" class="cell"><b>Buy</b>:</td>
                                    <td width="40%" align="left" class="cell"><b>Pay</b>:</td>
                                    <td width="30%" align="left" class="cell"><b>Seller</b>:</td>
                                </tr>
                                <?
  $result
= mysql_query("SELECT id,seller,hidename,credit_price,credit_sale FROM auction_main WHERE credit_price!='0' AND credit_sale!='0' ORDER BY credit_price+1 ASC") or die(mysql_error());
  $paantal = mysql_num_rows($result);
// keeps getting the next row until there are no more to get
    while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
?>

                                <tr>
                                    <td width="10%" align="left" class="cell"><input name="name" type="radio" value="<? echo $row['id']; ?>" onfocus="if(this.blur)this.blur()" /></td>
                                    <td width="20%" align="left" class="cell"><? echo number_format($row['credit_sale']); ?></td>
                                    <td width="40%" align="left" class="cell"><? echo "$ ".number_format($row['credit_price']).",-"; ?></td>
                                    <td width="30%" align="left" class="cell"><? if ( $hidename = 'yes' ) { echo "Anonymous"; }else{echo"<a href=\"view_profile.php?name=". $row['seller']."\" onFocus=\"if(this.blur)this.blur()\">".$row['seller']."</a>";} ?></td>
                                </tr>
                                <? }if ( $paantal == 0 )  {// while loop. ?>
                                <tr>
    <td colspan="4" align="center" valign="top" class="cell"><div align="center"><font color="#FF0000"><b>There are no point offers at this moment.</b></font></div></td>
  </tr>
  <?php }?>
                                <tr>
                                    <td colspan="4" align="right" class="submit"><input name="Cancel" type="submit" class="button" id="Cancel" onfocus="if(this.blur)this.blur()" value="Cancel."/>
                                        <input name="Purchase" type="submit" class="button" id="Purchase" onfocus="if(this.blur)this.blur()" value="Purchase."/></td>
                                </tr>
                            </table>
                            <br />
                            

 
                            <table width="100%" border="0" cellpadding="0" cellspacing="2" class="table">
                                <tr>
                                    <td colspan="2" align="left" class="head">Sell Points:</td>
                                </tr>
                                <tr>
                                    <td width="50" align="left" class="cell"><b>Points</b>:</td>
                                    <td width="200" align="center" class="cell"><div align="left">
                                      <input name="credits" type="text" class="entryfield" id="credits" />
                                      </div></td>
                                </tr>
                                <tr>
                                    <td width="50" align="left" class="cell"><b>Price</b>:</td>
                                    <td width="200" align="center" class="cell"><div align="left">
                                      <input name="price" type="text" class="entryfield" id="price" />
                                      </div></td>
                                </tr>
                                <tr>
                                    <td width="50" align="left" class="cell"><b>Stay Anonymous</b>:</td>
                                    <td width="200" align="center" class="cell"><div align="left">
                                      <input name="ptshidename" type="checkbox" id="ptshidename" value="yes" onfocus="if(this.blur)this.blur()"/>
                                      </div></td>
                                </tr>
                                <tr>
                                    <td colspan="2" align="right" class="submit"><input name="Add" type="submit" class="button" id="Add" onfocus="if(this.blur)this.blur()" value="Add."/></td>
                                </tr>
                            </table></td>
                    </tr>
                </table></td>
            <td valign="top"><table width="100%" align="center" cellspacing="5" class="table">
                    <tr>
                        <td align="left" class="sub"><b>Money Sales</b>: </td>
                    </tr>
                    <tr>
                        <td align="left" class="cell" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="2" class="table">
                                <tr>
                                    <td width="10%" align="left" class="cell"></td>
                                    <td width="20%" align="left" class="cell"><b>Buy</b>:</td>
                                    <td width="30%" align="left" class="cell"><b>Pay</b>:</td>
                                    <td width="40%" align="left" class="cell"><b>Seller</b>:</td>
                                </tr>
                                <?
  $result
= mysql_query("SELECT id,seller,hidename,money_price,money_sale FROM auction_main WHERE money_price!='0' AND money_sale!='0' ORDER BY money_price+1 ASC") or die(mysql_error());
  $maantal = mysql_num_rows($result);
// keeps getting the next row until there are no more to get
    while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
?>

                                <tr>
                                    <td width="10%" align="left" class="cell"><input id="name2" name="name2" type="radio" value="<? echo $row['id']; ?>" onfocus="if(this.blur)this.blur()" /></td>
                                    <td width="40%" align="left" class="cell"><? echo "$ ".number_format($row['money_sale']).",-"; ?></td>
                                    <td width="20%" align="left" class="cell"><? echo number_format($row['money_price']); ?></td>
                                    <td width="30%" align="left" class="cell"><? if ( $hidename == 'yes' ) { echo "Anonymous"; }else{echo"<a href=\"view_profile.php?name=". $row['seller']."\" onFocus=\"if(this.blur)this.blur()\">".$row['seller']."</a>";} ?></td>
                                </tr>
                                <? }if ( $maantal == 0 )  {// while loop. ?>
                                <tr>
    <td colspan="4" align="center" valign="top" class="cell"><div align="center"><font color="#FF0000"><b>There are no money offers at this moment.</b></font></div></td>
  </tr>
  <?php }?>
                                <tr>
                                    <td colspan="4" align="right" class="submit"><input name="Cancel2" type="submit" class="button" id="Cancel2" onfocus="if(this.blur)this.blur()" value="Cancel."/>
                                        <input name="Purchase2" type="submit" class="button" id="Purchase2" onfocus="if(this.blur)this.blur()" value="Purchase."/></td>
                                </tr>
                            </table>
                            <br />                            <?

if (in_array($name, $headmoderator_array) or in_array($name, $manager_array)){ ?>
    
<table width="100%" border="0" cellpadding="0" cellspacing="2" class="table">
                                <tr>
                                    <td colspan="2" align="left" ><div align="center"><font color="#FF0000"><b>As staff you aren't allowed to put up money auctions.</b></font></div></td>
                                </tr>
                                
                          </table>
                            <? }else{ ?>

                            <table width="100%" border="0" cellpadding="0" cellspacing="2" class="table">
                                <tr>
                                    <td colspan="2" align="left" class="head">Sell Money:</td>
                                </tr>
                                <tr>
                                    <td width="50" align="left" class="cell"><b>Money</b></td>
                                    <td width="200" align="center" class="cell"><div align="left">
                                      <input name="money2" type="text" class="entryfield" id="money2" />
                                      </div></td>
                                </tr>
                                <tr>
                                    <td width="50" align="left" class="cell"><b>Points</b>:</td>
                                    <td width="200" align="center" class="cell"><div align="left">
                                      <input name="credits2" type="text" class="entryfield" id="credits2" />
                                      </div></td>
                                </tr>
                                <tr>
                                    <td width="50" align="left" class="cell"><b>Stay Anonymous</b>:</td>
                                    <td width="200" align="center" class="cell"><div align="left">
                                      <input name="monhidename" type="checkbox" id="monhidename" value="yes" onfocus="if(this.blur)this.blur()"/>
                                      </div></td>
                                </tr>
                                <tr>
                                    <td colspan="2" align="right" class="submit"><input name="Add2" type="submit" class="button" id="Add2" onfocus="if(this.blur)this.blur()" value="Add."/></td>
                                </tr>                            </table>
                            <? } ?></td>

                    </tr>
                </table>
 
PHP hulp

PHP hulp

23/12/2024 11:16:12
 
Reforced

Reforced

30/10/2008 18:00:00
Quote Anchor link
Aanroepscript ziet er zo op het eerst oog goed uit; wat is de code van de functie zelf? ( $hidename )

(is als je hidename bent de waarde dan wel 'yes' ?)

Groet!
 
Eddy E

Eddy E

30/10/2008 18:02:00
Quote Anchor link
En waar stel je $hidename in?
Waarschijnlijk bestaat $row['hidename'] wel en zou je daarop moeten controleren.

En anders: echo $hidename eens... wat krijg je dan?
 
--

--

30/10/2008 18:05:00
Quote Anchor link
..
Gewijzigd op 01/01/1970 01:00:00 door --
 
Dennis

Dennis

30/10/2008 18:18:00
Quote Anchor link
@ Evert,

ik heb het zo ingeoast
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<? if ($row['hidename'] = 'yes') { echo "Anonymous"; }else{echo"<a href=\"view_profile.php?name=". $row['seller']."\" onFocus=\"if(this.blur)this.blur()\">".$row['seller']."</a>";} ?>


Maar nog steeds hetzelfde.

Elke veiling op die pagina word de verkoper als anoniem aangegeven... :(
 
--

--

30/10/2008 19:18:00
Quote Anchor link
..
Gewijzigd op 01/01/1970 01:00:00 door --
 
Thijs Damen

Thijs Damen

30/10/2008 19:32:00
Quote Anchor link
hmm.

Het teken =, is geen vergelijken. maar een opdracht,
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
$variable = 1,

echo $variable; //return 1;

wat jij doet is dan ook.
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
$row['hidename'] = 'yes';.
echo $row['hidename']; //return yes.

probeer eens een vergelijking

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
if ($row['hidename'] == 'yes') {


@Evert: even wakker worden nog :)?


even snel nog een editje.

@evert: je had zelf een typ gegeven 1 = te gebruiken (zie 2 posts hierboven, hij had het goed) ;)

@dennis. als je die ene = veranderd naar 2 == dan zou het moeten werken.
Gewijzigd op 01/01/1970 01:00:00 door Thijs Damen
 
--

--

30/10/2008 19:56:00
Quote Anchor link
..
Gewijzigd op 01/01/1970 01:00:00 door --
 
Thijs Damen

Thijs Damen

30/10/2008 20:01:00
Quote Anchor link
aye,
ik keek alleen naar regel 17 waar die het wel goed doet :)

achja kan gebeuren
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.