Reply to Please help me with my code

Your name:

Reply:


Posted by <juunksppamcrrap on 07/01/05 07:11

I've written the code below to perform the following:

Create a table that has three cells for each row. Each cell has a graphic and a radio button. The first row works fine. It gets to the third cell and starts creating the next row. The second row, however, just keeps creating cell after cell after cell, never getting around to creating the third row.

I have scoured this code for the reason, but I am obviously too close to the problem. Please help!

<?php

// Get the graphics, if any

$queryg = "SELECT * FROM spec_graphics WHERE graph_id >= '2' ORDER BY graph_id";
$resultg = mysql_query($queryg)
or die ("can't execute query. Refresh your browser to try again.");

$graph_num = mysql_num_rows($resultg);

if ($graph_num == "0")
{
// No graphics to display

echo <<<BLIMEY
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr align="center">
<td width="99%" height="50" class="back"><b>Delete a Graphic:<br />
At this time you have no uploaded custom graphics to delete</b></td>
</tr>
<tr align="center" valign="middle">
<td class="back"><img src="images/grey-span.gif" width="100%" height="3" /></td>
</tr>
</table>

BLIMEY;

}
else
{

// There is at least one graphic to display

echo <<<THEBEGIN
<form action="del_graph.php" method="post">
<input type="hidden" name="do" value="markit">
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr align="center">
<td height="50" colspan="3" class="back"><b>Delete a Graphic:</td>
</tr>
<tr align="center" valign="top">
<td height="10" colspan="3" class="back"><img src="images/grey-span.gif" width="100%" height="3" /></td>
</tr>

THEBEGIN;

$cell_num = "1";
$row_alter = "yes";

do
{
$rowg = mysql_fetch_array($resultg);
extract($rowg);

if ($row_alter == "yes")
{

if ($cell_num == "1")
{
echo <<<FARLEFTER
<tr align="center" valign="middle">
<td width="33%" class="tdgray"><img src="../special_images/$graph_loc" alt="$graph_id" width="100" /><br>
<input type="radio" name="kill_graph" value="$graph_id" /> Delete $graph_id</td>

FARLEFTER;

if ($graph_num == "1")
{
echo <<<FILLTHEREST
<td width="33%" class="tdgray">&nbsp;</td>
<td width="33%" class="tdgray">&nbsp;</td>
</tr>

FILLTHEREST;
}

$cell_num = "2";

}
elseif ($cell_num == "2")
{
echo <<<MIDDLIN
<td width="33%" class="tdgray"><img src="../special_images/$graph_loc" alt="$graph_id" width="100" /><br>
<input type="radio" name="kill_graph" value="$graph_id" /> Delete $graph_id</td>

MIDDLIN;
if ($graph_num == "1")
{
echo <<<FILLTHEREST
<td width="33%" class="tdgray">&nbsp;</td>
</tr>

FILLTHEREST;
}

$cell_num = "3";

}
else
{
echo <<<FARRIGHTER
<td width="33%" class="tdgray"><img src="../special_images/$graph_loc" alt="$graph_id" width="100" /><br>
<input type="radio" name="kill_graph" value="$graph_id" /> Delete $graph_id</td>
</tr>

FARRIGHTER;
$cell_num = "1";

$row_alter = "no";

}
}
else
{
if ($cell_num == "1")
{
echo <<<FARLEFTER
<tr align="center" valign="middle">
<td width="33%" class="back"><img src="../special_images/$graph_loc" alt="$graph_id" width="100" /><br>
<input type="radio" name="kill_graph" value="$graph_id" /> Delete $graph_id</td>

FARLEFTER;

if ($graph_num == "1")
{
echo <<<FILLTHEREST
<td width="33%" class="back">&nbsp;</td>
<td width="33%" class="back">&nbsp;</td>
</tr>

FILLTHEREST;
}

$cell_num = "2";

}
elseif ($cell_num == "2")
{
echo <<<MIDDLIN
<td width="33%" class="back"><img src="../special_images/$graph_loc" alt="$graph_id" width="100" /><br>
<input type="radio" name="kill_graph" value="$graph_id" /> Delete $graph_id</td>

MIDDLIN;
if ($graph_num == "1")
{
echo <<<FILLTHEREST
<td width="33%" class="back">&nbsp;</td>
</tr>

FILLTHEREST;
}

$cell_num == "3";

}
else
{
echo <<<FARRIGHTER
<td width="33%" class="back"><img src="../special_images/$graph_loc" alt="$graph_id" width="100" /><br>
<input type="radio" name="kill_graph" value="$graph_id" /> Delete $graph_id</td>
</tr>

FARRIGHTER;
$cell_num = "1";

$row_alter = "yes";

}
}

$graph_num--;

} while ($graph_num > "0");

echo <<<FINISHIT
<tr align="center" valign="bottom">
<td height="11" colspan="3" class="back">cell num=$cell_num, row alter=$row_alter, graph num=$graph_num<img src="images/grey-span.gif" width="100%" height="3" /></td>
</tr>
<tr align="center" valign="middle">
<td colspan="3" class="back"><input name="Submit" type="submit" value="Delete the Above Selected Graphic" /></td>
</tr>
<tr align="center" valign="middle">
<td colspan="3" class="back"><img src="images/grey-span.gif" width="100%" height="3" /></td>
</tr>
</table>
</form>

FINISHIT;

}

?>

There is obviously more to the code, but everything else works fine. It's just that darned second row!

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация