gordo2dope Posted July 24, 2007 Share Posted July 24, 2007 ive been working on this page for work and have this file exists script, it works, just not below the FETCH ARRAY line there. If i load the page and view source, it actually prints everything before and after the IF FILE EXISTS, but it totally skips that line. If i put a ; after the command then it reads it as false and displays the image. if tried this a million ways, anybody?? PS sorry it looks like crap, the spacing is all messed up when pasting into here. Ive tried that line with the {} and without and with different quotes and everything. <html> <head> <title>Motorclothes Parts Editor</title> </head> <body text="#000000"> <?php //CONNECT TO mczippo DATABASE mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("mczippo") or die(mysql_error()); $PartNum = $part['PartNum']; $Description = $part['Description']; $OnHand = $part['OnHand']; $Retail = $part['Retail']; $Theme = $part['Theme']; $Sale = $part['Sale']; $Detail = $part['Detail']; $Closeout = $part['Closeout']; $Sleeves = $part['Sleeves']; $Backprint = $part['Backprint']; $Color = $part['Color']; $Pocket = $part['Pocket']; $Picture = $part['Picture']; $Gender = $part['Gender']; $Size = $part['Size']; $OO = $part['OO']; $OrderOnly = $part['OrderOnly']; $Core = $part['Core']; $OBS = $part['OBS']; $Aftermarket = $part['Aftermarket']; $MinQty = $part['MinQty']; $Cat1 = $part['Cat1']; $Cat2 = $part['Cat2']; $SizeID = $part['SizeID']; $Active = $part['Active']; $Categ1 = $_GET['Categ1']; $Categ2 = $_GET['Categ2']; $Style = $_GET['Style']; $query = "SELECT * FROM `mczippo1` WHERE Style ='".$Style."' AND OnHand >= MinQty ORDER BY SizeID Asc"; $data = mysql_query( $query ); $part = mysql_fetch_array( $data ); echo " <center> <table cellpadding='2'cellspacing='2' border='0' align='center' width='70%'> <tr> <td align='center'>"; echo "<img src='images/motorclothes/" . $part['Cat1'] . "/" . $part['Cat2'] . "/" . $part['Style'] . ".jpg' name='targetimage'>"; echo " </form> </td> <td valign='middle' align='left'> <b><font color='red' size='-1'>ITEM # :</font><font size='+2'> " . $part['PartNum'] . "</font> <br> <font color='red' size='-1'>DESC :</font> " . $part['Description'] . " <br> <font color='red' size='-1'>PRICE :</font> $" . $part['Retail'] . " <br> <font color='red' size='-1'>CATEGORY :</font> " . $part['Cat1'] . " / " . $part['Cat2'] . " <BR> <font color='red' size='-1'>DETAIL :</font> " . $part['Detail'] . " <br>"; if ($part['Size'] == 'Does Not Apply' OR $part['Size'] == 'DoesNotApply' OR $part['Size'] == '') { echo ''; } else { echo ' <font color="red" size="-1"><b>IN STOCK :</font> <select action="noneyet" name="size"> <option value="" selected="selected"></option>'; do echo '<option value="' . $part['PartNum'] . '">' . $part['Size'] . '</option>'; while ($part = mysql_fetch_array( $data )AND $part['OnHand'] >= $part['MinQty']); }; echo "</select> </td> </td></tr><tr>"; if (file_exists("images/motorclothes/" . $part['Cat1'] . "/" . $part['Cat2'] . "/" . $part['Style'] . "2.jpg")) { echo "<td><img src='images/motorclothes/page/buttons/detail2.gif'></td>"; } echo " </tr></table>"; ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
vbnullchar Posted July 24, 2007 Share Posted July 24, 2007 Hmm.. try this in your query $query = "SELECT * FROM mczippo1 WHERE Style ='$Style' AND OnHand >= '$MinQty' ORDER BY SizeID Asc"; Quote Link to comment Share on other sites More sharing options...
gordo2dope Posted July 24, 2007 Author Share Posted July 24, 2007 well the problem im having is towards the bottom at this line where the do while is, it runs everything except that line, even with a ; after it it skips it, but runs the IMG SRC line. do echo '<option value="' . $part['PartNum'] . '">' . $part['Size'] . '</option>'; while ($part = mysql_fetch_array( $data )AND $part['OnHand'] >= $part['MinQty']); Quote Link to comment Share on other sites More sharing options...
gordo2dope Posted July 25, 2007 Author Share Posted July 25, 2007 ok once more im gonna clean this up and add pics too.. here is my PHP... [pre] <html> <head> <title>Motorclothes Parts Editor</title> </head> <body text="#000000"> <?php //CONNECT TO mczippo DATABASE mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("mczippo") or die(mysql_error()); $PartNum = $part['PartNum']; $Description = $part['Description']; $OnHand = $part['OnHand']; $Retail = $part['Retail']; $Theme = $part['Theme']; $Sale = $part['Sale']; $Detail = $part['Detail']; $Closeout = $part['Closeout']; $Sleeves = $part['Sleeves']; $Backprint = $part['Backprint']; $Color = $part['Color']; $Pocket = $part['Pocket']; $Picture = $part['Picture']; $Gender = $part['Gender']; $Size = $part['Size']; $OO = $part['OO']; $OrderOnly = $part['OrderOnly']; $Core = $part['Core']; $OBS = $part['OBS']; $Aftermarket = $part['Aftermarket']; $MinQty = $part['MinQty']; $Cat1 = $part['Cat1']; $Cat2 = $part['Cat2']; $SizeID = $part['SizeID']; $Active = $part['Active']; $Categ1 = $_GET['Categ1']; $Categ2 = $_GET['Categ2']; $Style = $_GET['Style']; $query = "SELECT * FROM `mczippo1` WHERE Style ='".$Style."' AND OnHand >= MinQty ORDER BY SizeID ASC"; $data = mysql_query( $query ); $part = mysql_fetch_array( $data ); echo " <center> <table cellpadding='2'cellspacing='2' border='0' align='center' width='70%'> <tr> <td align='center'>"; echo "<img src='images/motorclothes/" . $part['Cat1'] . "/" . $part['Cat2'] . "/" . $part['Style'] . ".jpg' name='targetimage'>"; echo " </td> <td valign='middle' align='left'> <b><font color='red' size='-1'>ITEM # :</font><font size='+2'> " . $part['Style'] . "</font> <br> <font color='red' size='-1'>DESC :</font> " . $part['Description'] . " <br> <font color='red' size='-1'>PRICE :</font> $" . $part['Retail'] . " <br> <font color='red' size='-1'>CATEGORY :</font> " . $part['Cat1'] . " / " . $part['Cat2'] . " <BR> <font color='red' size='-1'>DETAIL :</font> " . $part['Detail'] . " <br>"; if ($part['Size'] == 'Does Not Apply' OR $part['Size'] == 'DoesNotApply' OR $part['Size'] == '') { echo ''; } else { echo ' <font color="red" size="-1"><b>IN STOCK :</font> <select action="noneyet" name="size"> <option value="" selected="selected"></option>'; //THIS IS MY PROBLEM HERE!!! THIS LINE ENDS ANY QUERY FOR SOME REASON, AND //I HAVE TRIED TO CHANGE IT TO IF's AND WHILES AND THE ONLY THING THAT SEEMS TO WORK IS DO-WHILE do echo '<option value="' . $part['PartNum'] . '">' . $part['Size'] . '</option>'; while ($part = mysql_fetch_array( $data )AND $part['OnHand'] >= $part['MinQty']); } echo "</select> </td> </td></tr><tr>"; if (file_exists("images/motorclothes/" . $part['Cat1'] . "/" . $part['Cat2'] . "/" . $part['Style'] . "2.jpg")) { echo "<td><img src='images/motorclothes/page/buttons/detail2.gif'></td>"; } echo " </tr></table>"; ?> </body> </html> [/pre] NOW WHEN I VIEW THE PAGE IT LOOKS FINE AND THE SIZE DISPLAYER WORKS FINE, BUT IT SKIPS THE LAST LINE ABOUT THE FILE EXISTS. I KNOW THERE IS NOTHING WRONG WITH THAT LINE BECAUSE IT WORKS ABOVE THE "fetch array line" TOWARDS THE BOTTOM. BELOW IS THE HTML VIEW SOURCE OUTPUT. <html> <head> <title>Motorclothes Parts Editor</title> </head> <body text="#000000"> <center> <table cellpadding='2'cellspacing='2' border='0' align='center' width='70%'> <tr> <td align='center'><img src='images/motorclothes/Shirts/Mens/96286-00VM.jpg' name='targetimage'></td> <td valign='middle' align='left'> <b><font color='red' size='-1'>ITEM # :</font><font size='+2'> 96286-00VM</font> <br> <font color='red' size='-1'>DESC :</font> SHT-S/S,RACE,BLK/ORA <br> <font color='red' size='-1'>PRICE :</font> $45.00 <br> <font color='red' size='-1'>CATEGORY :</font> Shirts / Mens <BR> <font color='red' size='-1'>DETAIL :</font> SHT-S/S,RACE,BLK/ORA <br> <font color="red" size="-1"><b>IN STOCK :</font> <select action="noneyet" name="size"> <option value="" selected="selected"></option> <option value="96286-00VM/000S">SM</option> <option value="96286-00VM/000M">MD</option> <option value="96286-00VM/000L">LG</option> <option value="96286-00VM/002L">XL</option> <option value="96286-00VM/022L">2X</option> <option value="96286-00VM/222L">3X</option></select> </td> </td></tr> <tr> </tr></table> </body> </html> THIS IS WHAT THE DO-WHILE DOES... Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 25, 2007 Share Posted July 25, 2007 try??? while ($part = mysql_fetch_array( $data )) { if( $part['OnHand'] >= $part['MinQty'])){ echo '<option value="' . $part['PartNum'] . '">' . $part['Size'] . '</option>'; } else{ break; } } Quote Link to comment Share on other sites More sharing options...
gordo2dope Posted July 25, 2007 Author Share Posted July 25, 2007 well, that was a way to get out of the DO-WHILE, but the File_Exists still wont work, AND... the size options wont show the size for the PartNumber its using to display the picture because it already used that variable higher up. I dont know a way to have it check from the beginning again. say in the DATABASE TABLE there is SM, MD, LG, XL, 2X, 3X. Its using PartNum# 96286-00VM/000S and pulling the Details/price/etc. from that #, then when you get the the size selector it starts that WHILE with the next part number, and does not included the size SM even though it meets the CONDITION. Its because the Main Query at the top i have "ORDER BY SizeID" so after it puts them in order, it uses the first one to display the details on the page. BTW: i REALLy appreciate anybody who even opens this topic, THANKS! Quote Link to comment Share on other sites More sharing options...
gordo2dope Posted July 25, 2007 Author Share Posted July 25, 2007 Actually all i did to fix it was copy and paste the quesry AFTER the D-WHILE and change the variable name, so it should be starting the search over again, allowing me to RE-use the first # it found. [pre] echo ' <font color="red" size="-1"><b>IN STOCK :</font> <select action="noneyet" name="size"> <option value="" selected="selected"></option>'; do echo '<option value="' . $part['PartNum'] . '">' . $part['Size'] . '</option>'; while ($part = mysql_fetch_array( $data )AND $part['OnHand'] >= $part['MinQty']); } echo "</select> </td> </td></tr><tr>"; $query2 = "SELECT * FROM `mczippo1` WHERE Style ='".$Style."' AND OnHand >= MinQty ORDER BY SizeID ASC"; $data2 = mysql_query( $query2 ); $part2 = mysql_fetch_array( $data2 ); if (file_exists("images/motorclothes/" . $part2['Cat1'] . "/" . $part2['Cat2'] . "/" . $part2['Style'] . "3.jpg")) { echo "<td><img src='images/motorclothes/page/buttons/detail2.gif'></td>"; } echo " </tr></table>"; ?> [/pre] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.