Re: If else question
| From: | Jennifer Downey | Date: | Tue, 23 Apr 2002 18:26:18 +0000 |
| Subject: | Re: If else question | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-94223@lists.php.net to get a copy of this message | ||
You are on the right track.
"-Bd-" <bd@rfbdproductions.com> wrote in message
news:00a301c1eaf3$b181a260$59c71cd8@rfbdproductions.com...
> am i off on the wrong track here? i thought the original problem was that
> both clauses in the if statement were exectuting (the 'if' and the
'else')?
>
>
>
>
>
>
> > Now, we're getting somewhere!!!
> >
> > First, have you printed out $query to ensure it contains what you
> expected?
> > Show us.
> >
> > Second, are you certain the mysql_query() is successful? I ask, because
> you
> > don't have the "or die()" that SHOULD be on all queries.
> >
> > Third, have you printed out all the values fetched via
mysql_fetch_array()
> > to ensure they contain valid data?
> >
> > ----- Original Message -----
> > From: Jennifer Downey <jendowney@attbi.com>
> > To: <php-general@lists.php.net>
> > Sent: Tuesday, April 23, 2002 12:48 PM
> > Subject: Re: [PHP] If else question
> >
> >
> > Ok you asked for it.
> > Don't say I didn't warn you.
> >
> > session_start();
> > $query = "SELECT name FROM {$config["prefix"]}_users WHERE
> > uid={$session["uid"]}";
> > $ret = mysql_query($query);
> > while($row = mysql_fetch_array($ret))
> > {
> >
> > $user = $row['name'];
> >
> >
> >
> > $query = "SELECT uid, id, iname, image, quantity, type FROM
> > {$config["prefix"]}_my_items WHERE uid={$session["uid"]} AND id =
> > '$id'
> > ORDER BY id";
> > $ret = mysql_query($query);
> > while($row = mysql_fetch_array($ret))
> > {
> > $uiid = $row['uid'];
> > $iid = $row['id'];
> > $image = $row['image'];
> > $iname = $row['iname'];
> > $quantity = $row['quantity'];
> > $type = $row['type'];
> > // this is the problem if statement. Please don't yell at me for my
style.
> > It is easy for me to read so I'm sorry if it's not for you.
> > if($quantity < 1)
> > {
> > echo "Sorry I can't seem to locate this item";
> > }
> > else
> > {
> >
> > session_register("uiid");
> > session_register("iid");
> > session_register("image");
> > session_register("iname");
> > session_register("quantity");
> > session_register("type");
> >
> >
> > if($iid == $id)
> > {
> >
> > $display_block .="<CENTER><img src=$image border=0><br><font
> > size =
> > 2>$iname<BR>$quantity<BR>$type<BR></font></CENTER>";
> >
> > echo "$display_block<BR><BR>";
> >
> > if($type == "food")
> > file://if the item food is present then set an option and include
in
> > the
> > form later
> > {
> > $thisoption="<OPTION VALUE=\"feed\">Feed my
> > pet\n</OPTION>";
> > }
> > else
> > {
> > file://if book or weapon is present then set a blank
> > $thisoption="";
> > }
> > }
> > }
> > }
> > }
> > file://check if form has been submitted
> > if($submit)
> > {
> >
> > }
> > else
> > {
> >
> > file://if the form has not been submitted run the following
> >
> >
> > echo "<FORM ACTION='$PHP_SELF' METHOD='post'>";
> > echo "<SELECT NAME='sort' SIZE='1' >";
> > echo "$thisoption";
> > echo "<OPTION VALUE='shop'>Put in my shop</OPTION>";
> > echo "<OPTION VALUE='locker'>Put into my
> > Footlocker</OPTION>";
> > echo "<OPTION VALUE='discard'>Discard this
> > item</OPTION>";
> > echo "<OPTION VALUE='donate'>Donate this
> > item</OPTION>";
> > echo "</SELECT>";
> > echo "<INPUT TYPE='submit' VALUE='Submit'
> > NAME='submit'>";
> > echo "</FORM>";
> >
> >
> > }
> >
> > Jennifer
>
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002