daniel5455 Posted August 18, 2008 Share Posted August 18, 2008 I am no coder so bear with me. I took a page that was in html and tried to convert it into php where it pulls the info from a mysql db. If i have 1 row of items it looks good. but if i add more items to the database the following rows indent in making everything messed up. Here is the code if anyone can help me find the problem. <?php session_start();?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title></title> </head> <body> <center> <table width="100%" id="table1"> <tr> <td align="center" width="100%"> <table cellspacing="0" cellpadding="0" id="table2"> <tr> <td align="center" width="100%"> <table cellspacing="0" cellpadding="0" border="0" id="table3"> <tr> <td valign="top" width="650"> <table border="2" id="table4"> <tr> <td align="center" width="100%" bgcolor="white"> <table border="0" width="100%" id="table38"> <tr> <td> <p align="center"> <img border="0" src="images/Valcon-logo1.gif" alt="" width="137" height="73"><br> <font face="Verdana" size="1"> <br> <br> <br> </font></p> </td> <td width="302"> <p align="center"><b> <font face="Verdana" size="4"> <font color="#003399"></font><font color="#0000FF"></font><br> </font></b> <font face="Verdana" size="1">Prices subject to change without notice.</font></p> </td> <td width="166"> <p align="center"> <img border="0" src="../../images/hp_logo.jpg" alt="Hewlett Packard" width="126" height="81"></p> </td> </tr> </table> <?php $con = mysql_connect('localhost', '_siteusr', '@n') or die('Could not connect: ' . mysql_error()); mysql_select_db('valcon', $con) or die('Could not select database'); if($_GET['id'] != null) { $r = mysql_query("select image from product where id=".$_GET['id']); if($ro = mysql_fetch_array($r)) { if(is_file($ro['image'])) unlink('productimages//'.$ro['image']); } mysql_query("delete from product where id=".$_GET['id']); } $result = mysql_query("select * from product"); echo '<table cellspacing="0" cellpadding="0" border="0" id="table5"> <tr> <td valign="top" align="middle" bgcolor="white"> <table cellspacing="0" cellpadding="0" width="100%" border="0" id="table6"> <tr> <td valign="top"> <table cellspacing="0" cellpadding="5" width="100%" border="0" id="table7"> <tr>'; while($row = mysql_fetch_array($result)) { echo '<tr>'; echo '<td class="pl_image" width="20%"><img src= "productimages/' . $row['image']. '" width="100" height="100" cellpadding="10"></td> <td valign="top" width="240" class="pi_title" width="20%"><b>'.$row['title'].'</b><br><font size="1">'.$row['processor'].'<br>'.$row['memory'].'<br>'.$row['hdd'].'<br>'.$row['cdrom'].'<br>'.$row['display'].'<br>'.$row['os'].'<br>'.$row['warranty'].'<br>'.$row['other'].'</font> </td> <td valign="bottom" align="middle" width="230"><b><font face="Verdana" size="2">Item #: '.$row['item#'].'</b><b><br>'.$row['price'].'<br>Free Ground Shipping</b><br><br><font size="1">For faster shipping please add:</font></font> <table width="100%" border="0" id="table34"> <tr> <td class="data" align="middle" bgcolor="#f3f4ec"><font face="Verdana" size="1">' . $row['ship3']. '</font> </td> <td class="data" align="middle" bgcolor="#f3f4ec"><font face="Verdana" size="1"><b>' . $row['ship3price']. '</b> </font> </td> </tr> <tr> <td class="data" align="middle" bgcolor="#f3f4ec"><font face="Verdana" size="1">' . $row['ship2']. '</font></td><td class="data" align="middle" bgcolor="#f3f4ec"><font face="Verdana" size="1"><b>' . $row['ship2price']. '</b> </font> </td> </tr> <tr> <td class="data" align="middle" bgcolor="#f3f4ec"><font face="Verdana" size="1">' . $row['ship1']. '</font> </td> <td class="data" align="middle" bgcolor="#f3f4ec"><font face="Verdana" size="1"><b>' . $row['ship1price']. '</b> </font> </td> </tr> <br>'; if ($_SESSION["usertype"]!= null && $_SESSION["usertype"] == "admin") echo '<td><a href="./products.php?id='.$row['id'].'">Delete</a></td>'; echo '</tr>'; } echo '</table> </td> </tr> </table> </td> </tr> </table> </td> </tr>'; if ($_SESSION["usertype"] == "admin") echo '<p align = "right"> <a href="addproducts.php"><strong>Add a new product</strong></a> </p>'; mysql_free_result($result); mysql_close($con); ?> <td colspan="8" height="1"> <img height="1" src="../images/border.gif" width="620" border="0"></td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </center> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/120135-need-help-troubleshooting-this/ Share on other sites More sharing options...
MasterACE14 Posted August 18, 2008 Share Posted August 18, 2008 you've only added session_start(); to the beginning, and you haven't done anything else... Please have a go at doing this yourself first. Read some tutorials. Download some free scripts. Once you have done some more. Post your code if you have trouble and we'll see what we can do to help you. Quote Link to comment https://forums.phpfreaks.com/topic/120135-need-help-troubleshooting-this/#findComment-618943 Share on other sites More sharing options...
.josh Posted August 18, 2008 Share Posted August 18, 2008 He does have code posted in there. It's about halfway down and starts about halfway to the right. On that note, if you want some serious help then you need to edit or repost your code to a more readable format. Nobody is gonna want to even attempt helping you if they got to go through the trouble of formatting it first. Quote Link to comment https://forums.phpfreaks.com/topic/120135-need-help-troubleshooting-this/#findComment-618946 Share on other sites More sharing options...
daniel5455 Posted August 18, 2008 Author Share Posted August 18, 2008 i tried to cleanup as best as i can hopefully this is more readable. <?php session_start();?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Language" content="en-us" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title></title> </head> <body> <center> <table width="100%" id="table1"> <tr> <td align="center" width="100%"> <table cellspacing="0" cellpadding="0" id="table2"> <tr> <td align="center" width="100%"> <table cellspacing="0" cellpadding="0" border="0" id="table3"> <tr> <td "valign="top" width="650"> <table border="2" id="table4"> <tr> <td align="center" width="100%" bgcolor="white"> <table border="0" width="100%" id="table38"> <tr> <td> <p align="center"> <img border="0" src="images/Valcon-logo1.gif" alt="Valcon" width="137" height="73" /><br /> <font face="Verdana" size="1"> <br /> <br /> <br /> </font></p></td> <td width="302"> <p align="center"><b> <font face="Verdana" size="4"> <font color="#003399">VALCON</font><font color="#0000FF">REFURBISHED LAPTOPS</font><br /> </font></b> <font face="Verdana" size="1">Prices subject to change without notice.</font></p></td> <td width="166"> <p align="center"> <img border="0" src="../../images/hp_logo.jpg" alt="Hewlett Packard" width="126" height="81" /></p></td> </tr> </table> <?php $con = mysql_connect('localhost', 'siteusr', 'pass') or die('Could not connect: ' . mysql_error()); mysql_select_db('valcon', $con) or die('Could not select database'); if($_GET['id'] != null) { $r = mysql_query("select image from product where id=".$_GET['id']); if($ro = mysql_fetch_array($r)) { if(is_file($ro['image'])) unlink('productimages//'.$ro['image']); } mysql_query("delete from product where id=".$_GET['id']); } $result = mysql_query("select * from product"); echo ' <table cellspacing="0" cellpadding="0" border="0" id="table5"> <tr> <td valign="top" align="center" bgcolor="white"> <table cellspacing="0" cellpadding="0" width="100%" border="0" id="table6"> <tr> <td valign="top"> <table cellspacing="0" cellpadding="5" width="100%" border="0" id="table7"> <tr>'; while($row = mysql_fetch_array($result)) { echo ' <tr>'; echo ' <td class="pl_image" width="20%"><img src= "productimages/' . $row['image']. '" width="100" height="100" cellpadding="10"></td> <td valign="top" width="240" class="pi_title" width="20%"> <b>'.$row['title'].'</b><br> <font size="1">'.$row['processor'].'<br> '.$row['memory'].'<br> '.$row['hdd'].'<br> '.$row['cdrom'].'<br> '.$row['display'].'<br> '.$row['os'].'<br> '.$row['warranty'].'<br> '.$row['other'].'</font> </td> <td valign="bottom" align="center" width="230"><b><font face="Verdana" size="2">Item #: '.$row['item#'].'</b><b><br> '.$row['price'].'<br> Free Ground Shipping</b><br> <br> <font size="1">For faster shipping please add:</font></font> <table width="100%" border="0" id="table34"> <tr> <td class="data" align="center" bgcolor="#f3f4ec"><font face="Verdana" size="1">' . $row['ship3']. '</font> </td> <td class="data" align="center" bgcolor="#f3f4ec"><font face="Verdana" size="1"><b>' . $row['ship3price']. '</b> </font> </td> </tr> <tr> <td class="data" align="center" bgcolor="#f3f4ec"><font face="Verdana" size="1">' . $row['ship2']. '</font></td> <td class="data" align="center" bgcolor="#f3f4ec"><font face="Verdana" size="1"><b>' . $row['ship2price']. '</b> </font> </td> </tr> <tr> <td class="data" align="center" bgcolor="#f3f4ec"><font face="Verdana" size="1">' . $row['ship1']. '</font> </td> <td class="data" align="center" bgcolor="#f3f4ec"><font face="Verdana" size="1"><b>' . $row['ship1price']. '</b> </font> </td> </tr> '; if ($_SESSION["usertype"]!= null && $_SESSION["usertype"] == "admin") echo ' <td><a href="./products.php?id='.$row['id'].'">Delete</a></td> '; echo '</tr> '; } echo ' </table></td> </tr> </table> </td> </tr> </table> </td> </tr> '; if ($_SESSION["usertype"] == "admin") echo ' <p align = "right"> <a href="addproducts.php"><strong>Add a new product</strong></a> </p> '; mysql_free_result($result); mysql_close($con); ?> </td> <td colspan="8" height="1"> <img height="1" src="../images/border.gif" width="620" border="0" /></td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </center> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/120135-need-help-troubleshooting-this/#findComment-619284 Share on other sites More sharing options...
daniel5455 Posted August 18, 2008 Author Share Posted August 18, 2008 bump Quote Link to comment https://forums.phpfreaks.com/topic/120135-need-help-troubleshooting-this/#findComment-619569 Share on other sites More sharing options...
unkwntech Posted August 18, 2008 Share Posted August 18, 2008 Tip 1: Don't put HTML inside PHP, instead put PHP inside HTML. Tip 2: Put each item on a different line. Give this a try: <?php $con = mysql_connect('localhost', 'siteusr', 'pass') or die('Could not connect: ' . mysql_error()); mysql_select_db('valcon', $con) or die('Could not select database'); if($_GET['id'] != null) { $r = mysql_query("select image from product where id=".$_GET['id']); if($ro = mysql_fetch_array($r)) { if(is_file($ro['image'])) unlink('productimages//'.$ro['image']); } mysql_query("delete from product where id=".$_GET['id']); } $result = mysql_query("select * from product"); ?> <table cellspacing="0" cellpadding="0" border="0" id="table5"> <tr> <td valign="top" align="center" bgcolor="white"> <table cellspacing="0" cellpadding="0" width="100%" border="0" id="table6"> <tr> <td valign="top"> <table cellspacing="0" cellpadding="5" width="100%" border="0" id="table7"> <tr> <?php while($row = mysql_fetch_array($result)) { ?> <tr> <td class="pl_image" width="20%"><img src= "productimages/<?php echo $row['image']; ?>" width="100" height="100" cellpadding="10"></td> <td valign="top" width="240" class="pi_title" width="20%"> <b><?php echo $row['title']; ?></b><br> <font size="1"><?php echo $row['processor']; ?><br> <?php echo $row['memory']; ?><br> <?php echo $row['hdd']; ?><br> <?php echo $row['cdrom']; ?><br> <?php echo $row['display']; ?><br> <?php echo $row['os']; ?><br> <?php echo $row['warranty']; ?><br> <?php echo $row['other']; ?></font> </td> <td valign="bottom" align="center" width="230"><b><font face="Verdana" size="2">Item #: <?php echo $row['item#']; ?></b><b><br> <?php echo $row['price']; ?><br> Free Ground Shipping</b><br> <br> <font size="1">For faster shipping please add:</font></font> <table width="100%" border="0" id="table34"> <tr> <td class="data" align="center" bgcolor="#f3f4ec"><font face="Verdana" size="1"><?php echo $row['ship3']; ?></font> </td> <td class="data" align="center" bgcolor="#f3f4ec"><font face="Verdana" size="1"><b><?php echo $row['ship3price']; ?></b> </font> </td> </tr> <tr> <td class="data" align="center" bgcolor="#f3f4ec"><font face="Verdana" size="1"><?php echo $row['ship2']; ?></font></td> <td class="data" align="center" bgcolor="#f3f4ec"><font face="Verdana" size="1"><b><?php echo $row['ship2price']; ?></b> </font> </td> </tr> <tr> <td class="data" align="center" bgcolor="#f3f4ec"><font face="Verdana" size="1"><?php echo $row['ship1']; ?></font> </td> <td class="data" align="center" bgcolor="#f3f4ec"><font face="Verdana" size="1"><b><?php echo $row['ship1price']; ?></b> </font> </td> </tr> <?php if ($_SESSION["usertype"]!= null && $_SESSION["usertype"] == "admin") { ?> <td><a href="./products.php?id=<?php echo $row['id']; ?>">Delete</a></td> </tr> <?php } ?> </table></td> </tr> </table> </td> </tr> </table> </td> </tr> <?php if ($_SESSION["usertype"] == "admin") { ?> <p align = "right"> <a href="addproducts.php"><strong>Add a new product</strong></a> </p> <?php } mysql_close($con); ?> Quote Link to comment https://forums.phpfreaks.com/topic/120135-need-help-troubleshooting-this/#findComment-619581 Share on other sites More sharing options...
daniel5455 Posted August 18, 2008 Author Share Posted August 18, 2008 Thanks for your time in helping me. but i get this error Parse error: syntax error, unexpected $end in file.php on line 82 Quote Link to comment https://forums.phpfreaks.com/topic/120135-need-help-troubleshooting-this/#findComment-619622 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.