Re: :(

From: Date: Sun, 29 Jul 2001 19:53:30 +0000
Subject: Re: :(
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-60108@lists.php.net to get a copy of this message
Define "not work" Some tips : 1. echo your query, make sure it appears as intended. In otherwords, make sure the variables $table and $category contain proper data. echo $sql; 2. make use of mysql_error() function as it can be useful. echo mysql_error(); For example, you may want to do this after your $result, see manual for more details on this helpful function. There are many ways to use it, some people would do this : $result = mysql_query($sql) or die(mysql_error()); Eventually you'll learn other ways that help control errors but in the above if a mysql error exists it'll print it and the script will die/exit. 3. In a question always report the exact error or what is not working, it's much more efficient for us as it means less guessing and less brain power to solve the problem. "not work" can mean many things. As can ":(" ;-) 4. The code may be easier to read if the block of html is written as html, not PHP. Not that big of deal but don't be afraid to break out into "html mode". For example, the following is appropriate (I don't know what you know but some don't know this so ...) <?php if ($foo == 'bar') { // If $foo equals to 'bar' then the form below will be printed. ?> Hi friend, please fill out this form. <form method="post" action="process.php"> Name : <input type="text" name="name"><br> Email : <input type="text" name="email"> </form> We appreciate this, todays color is <?php echo $color ?>, be sure to watch out for it. <?php } ?> Hope the above digression helps. Regards, Philip Ldl Enterprise wrote: > I cannot figure out why this button does not work any suggestions > are appreciated. Thanks. > > > > > $table = "inventory"; > $sql = "SELECT * FROM $table where category='$category'"; > $result = mysql_query($sql); > > while ($myrow = mysql_fetch_array($result)) > { > printf("<tr><td border=1 bgcolor=#A0AAB9><font face=Lucida Sans Unicode > size=4><form><input type=button value=%s > onclick=javascript:window.open('view_pict.php?picture_id=%s.gif','MyWind > ow','width=450,height=600,menubar=no,scrollbars=yes,toolbar=no,location= > > no,directories=no,resizable=yes,top=0,left=0')></form></font></td></tr> > \n", $myrow["product"], $myrow["product"]); > } >

« previous php.general (#60108) next »