Jump to content

HELP w/ File_EXISTS


gordo2dope

Recommended Posts

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>

Link to comment
Share on other sites

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']);

Link to comment
Share on other sites

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...

 

looppic.jpg

Link to comment
Share on other sites

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!

 

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.