sandbudd Posted July 28, 2010 Share Posted July 28, 2010 Could someone please tell me why this displays 3 columns correct and then all moves over. Here is the page you can see what I am talking about http://www.woodrun.org/includes/news.php I have looked the code over and over and can't see it. Thanks in advance. <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $maxRows_Recordset1 = 1000000; $pageNum_Recordset1 = 0; if (isset($_GET['pageNum_Recordset1'])) { $pageNum_Recordset1 = $_GET['pageNum_Recordset1']; } $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; mysql_select_db($database_woodrun, $woodrun); $query_Recordset1 = "SELECT * FROM news ORDER BY id DESC" ; $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1); $Recordset1 = mysql_query($query_limit_Recordset1, $woodrun) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); if (isset($_GET['totalRows_Recordset1'])) { $totalRows_Recordset1 = $_GET['totalRows_Recordset1']; } else { $all_Recordset1 = mysql_query($query_Recordset1); $totalRows_Recordset1 = mysql_num_rows($all_Recordset1); } $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1; ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_fwragain, $fwragain); $query_Recordset1 = "SELECT * FROM news ORDER BY id DESC"; $Recordset1 = mysql_query($query_Recordset1, $woodrun) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <table width="100%" border="0" align="center" cellpadding="5" cellspacing="5"> <?php do { ?> <tr> <td colspan="4" align="left" valign="top"><?php echo "<img src=http://woodrun.org/images/".$row_Recordset1['photo'] ."> "; ?></td> <td width="550" align="left" valign="top"><?php echo $row_Recordset1['title']; ?> <hr /> <?php echo $row_Recordset1['article']; ?><br /></td> </tr> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> </table> <?php mysql_free_result($Recordset1); ?> Link to comment https://forums.phpfreaks.com/topic/209154-displaying-wrong/ Share on other sites More sharing options...
radar Posted July 28, 2010 Share Posted July 28, 2010 try it this way $totalRows_Recordset1 = mysql_num_rows($Recordset1); $i = 0; ?> <table width="100%" border="0" align="center" cellpadding="5" cellspacing="5"> <?php while ($i <= $totalRows_Recordset1) { ?> <tr> <td colspan="4" align="left" valign="top"><?php echo "<img src=http://woodrun.org/images/".$row_Recordset1['photo']."> "; ?></td> <td width="550" align="left" valign="top"><?php echo $row_Recordset1['title']; ?> <hr /> <?php echo $row_Record_set1['article']; ?><br /> </td> </tr> <?php $i++; } ?> </table> edit: i forgot the $i++ at the end of the loop. Link to comment https://forums.phpfreaks.com/topic/209154-displaying-wrong/#findComment-1092308 Share on other sites More sharing options...
sandbudd Posted July 28, 2010 Author Share Posted July 28, 2010 radar what that produced was the last entry 6 times with the description missing. Link to comment https://forums.phpfreaks.com/topic/209154-displaying-wrong/#findComment-1092311 Share on other sites More sharing options...
radar Posted July 28, 2010 Share Posted July 28, 2010 alright lemme rework it or just add this into the while line of the code: $row_Recordset1 = mysql_fetch_assoc($Recordset1); so it would look like: while($i <= $totalRows_Recordset1 && $row_Recordset1 = mysql_fetch_assoc($Recordset1)) { Link to comment https://forums.phpfreaks.com/topic/209154-displaying-wrong/#findComment-1092312 Share on other sites More sharing options...
sandbudd Posted July 28, 2010 Author Share Posted July 28, 2010 thanks Link to comment https://forums.phpfreaks.com/topic/209154-displaying-wrong/#findComment-1092313 Share on other sites More sharing options...
radar Posted July 28, 2010 Share Posted July 28, 2010 $totalRows_Recordset1 = mysql_num_rows($Recordset1); $i = 0; ?> <table width="100%" border="0" align="center" cellpadding="5" cellspacing="5"> <?php while ($i <= $totalRows_Recordset1 && $row_Recordset1 = mysql_fetch_assoc($Recordset1)) { ?> <tr> <td colspan="4" align="left" valign="top"><?php echo "<img src=http://woodrun.org/images/".$row_Recordset1['photo']."> "; ?></td> <td width="550" align="left" valign="top"><?php echo $row_Recordset1['title']; ?> <hr /> <?php echo $row_Recordset1['article']; ?><br /> </td> </tr> <?php $i++; } ?> </table> there, now even if it just sticks with the 1 article, it'll have the description -- i had an unwanted underscore in the variable name of that echo. Link to comment https://forums.phpfreaks.com/topic/209154-displaying-wrong/#findComment-1092314 Share on other sites More sharing options...
sandbudd Posted July 28, 2010 Author Share Posted July 28, 2010 still not doing it all that happened was it removed the last one to display Link to comment https://forums.phpfreaks.com/topic/209154-displaying-wrong/#findComment-1092318 Share on other sites More sharing options...
radar Posted July 28, 2010 Share Posted July 28, 2010 Do you have it somewhere that I could see what it's doing so i can see what and where i need to change it? Link to comment https://forums.phpfreaks.com/topic/209154-displaying-wrong/#findComment-1092322 Share on other sites More sharing options...
sandbudd Posted July 28, 2010 Author Share Posted July 28, 2010 http://www.woodrun.org/includes/news.php Link to comment https://forums.phpfreaks.com/topic/209154-displaying-wrong/#findComment-1092323 Share on other sites More sharing options...
Pikachu2000 Posted July 28, 2010 Share Posted July 28, 2010 That code is inserting a table within a <TD> of an already open table. That's where your problem lies. Link to comment https://forums.phpfreaks.com/topic/209154-displaying-wrong/#findComment-1092324 Share on other sites More sharing options...
radar Posted July 28, 2010 Share Posted July 28, 2010 hmm the html output of whats up, is completely different than what we have up.. let me look at that html output a bit and see where the error might be... $totalRows_Recordset1 = mysql_num_rows($Recordset1); $i = 0; ?> <table width="100%" border="0" align="center" cellpadding="5" cellspacing="5"> <?php while ($i <= $totalRows_Recordset1 && $row_Recordset1 = mysql_fetch_assoc($Recordset1)) { ?> <tr> <td colspan="4" align="left" valign="top"><?php echo "<img src=http://woodrun.org/images/".$row_Recordset1['photo']."> "; ?></td> <td width="550" align="left" valign="top"><?php echo $row_Recordset1['title']; ?><hr /><?php echo $row_Recordset1['article']; ?></td> </tr> <?php $i++; } ?> </table> try this, see if this helps.. looking at the source code this could fix the issue. Link to comment https://forums.phpfreaks.com/topic/209154-displaying-wrong/#findComment-1092328 Share on other sites More sharing options...
radar Posted July 28, 2010 Share Posted July 28, 2010 lets just try something for shits and giggles... take out the <table width="100%" border="0" align="center" cellpadding="5" cellspacing="5"> line all together... i just spotted a spot that has that listed twice one under the other. Link to comment https://forums.phpfreaks.com/topic/209154-displaying-wrong/#findComment-1092332 Share on other sites More sharing options...
sandbudd Posted July 28, 2010 Author Share Posted July 28, 2010 no difference Link to comment https://forums.phpfreaks.com/topic/209154-displaying-wrong/#findComment-1092335 Share on other sites More sharing options...
radar Posted July 28, 2010 Share Posted July 28, 2010 if the HTML output wasnt so different than what we've got here this would be easier but it nearly completely changes... unless all that xml and css stuff is in the database stored with the 'article'... this is confusing me though Link to comment https://forums.phpfreaks.com/topic/209154-displaying-wrong/#findComment-1092339 Share on other sites More sharing options...
sandbudd Posted July 28, 2010 Author Share Posted July 28, 2010 it is Link to comment https://forums.phpfreaks.com/topic/209154-displaying-wrong/#findComment-1092340 Share on other sites More sharing options...
radar Posted July 28, 2010 Share Posted July 28, 2010 any particular reason why? Link to comment https://forums.phpfreaks.com/topic/209154-displaying-wrong/#findComment-1092341 Share on other sites More sharing options...
sandbudd Posted July 28, 2010 Author Share Posted July 28, 2010 because the person inputing the information can change font color etc... Link to comment https://forums.phpfreaks.com/topic/209154-displaying-wrong/#findComment-1092344 Share on other sites More sharing options...
radar Posted July 28, 2010 Share Posted July 28, 2010 Look in the database for the entry titled It (the 2nd one), im willing to bet the issue lies there since thats where the issue starts. in fact, right at the beginning of it somewhere, you probably have: <table width="100%" align="center" border="0" cellpadding="5" cellspacing="5"> in there... Link to comment https://forums.phpfreaks.com/topic/209154-displaying-wrong/#findComment-1092345 Share on other sites More sharing options...
sandbudd Posted July 28, 2010 Author Share Posted July 28, 2010 it was in the database...it works fine Thanks Link to comment https://forums.phpfreaks.com/topic/209154-displaying-wrong/#findComment-1092350 Share on other sites More sharing options...
radar Posted July 28, 2010 Share Posted July 28, 2010 looks much better might want to add in some idiot proofing to the inputs so that, this doesnt happen again Link to comment https://forums.phpfreaks.com/topic/209154-displaying-wrong/#findComment-1092351 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.