mbradley Posted July 4, 2008 Share Posted July 4, 2008 Now i am not sure Y the heck this is happening and i thought it was simple but i have been working at it for 2 long think i need some new eyes looking at it:( Can someone assit me? please:( I have table with 5 rows... 1 2 3 4 5 and it only prints 1,3,5 I don't see anything that would do that in my script but i prolly am missing it... please help me:( <?php define('_VALID_INCLUDE', TRUE); session_start(); if(!session_is_registered(myusername)){ header("location:index.php"); } $user = $_SESSION['myusername']; $rank = $_SESSION['rank']; $access = $_SESSION['cds']; if($access == 0) { echo 'Sorry you don\'t have the right to access this page.<br>'; echo '<a href="../">Back to main page</a><br>'; echo '<a href="logout">LOGOUT</a><br>'; }else{ include 'lib/config.php'; include 'lib/opendb.php'; if($rank == 1){ $ranktitle = 'ADMIN'; $sqlowner = "SELECT DISTINCT name FROM CD"; $result_buyers = mysql_query($sqlowner) or die(mysql_error()); $sql = "SELECT * FROM `CD`"; } else { $ranktitle = 'Buyer'; $sql = "SELECT * FROM `CD` WHERE name = '$user'"; } $result = mysql_query($sql) or die(mysql_error()); echo '<center>'; echo '<a href="logout">LOGOUT</a><br>'; echo ' --=-- '; echo "Login Status: ",$ranktitle; echo ' --=-- '; if($rank == 1){ echo 'Total Buyers: ', mysql_num_rows($result_buyers); echo ' --=-- '; echo 'Total Purchases: ', mysql_num_rows($result); echo ' --=-- '; } else{ echo 'Total Downloads: ', mysql_num_rows($result); echo ' --=-- '; } echo "<table border='1'>"; echo "<tr><th>Track</th><th>download</th>"; echo "<th>BUYER</th><th>purchased</th>"; echo "</tr>"; if($rank == 1){$sql = "SELECT * FROM `CD`";}else{$sql = "SELECT * FROM `CD` WHERE name = '$user'";} // keeps getting the next row until there are no more to get $result1 = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($result1)) { // Print out the contents of each row into a table echo "<tr><td><center>"; echo $row[track]; echo "</center></td><td><center>"; ?> <a href="download.php?f=<?php echo $row[fname];?>'> <?php echo $row[fname]; echo "</a></center>"; echo "</td><td><center>"; echo $row[name]; echo "</center></td><td><center>"; echo $row[rltime]; echo "</center></td></tr>"; } ?> </table><center><br><br> Created for us with Second Life<br>Saladin NightFire<br>Wolf Creations </center> <?php include 'lib/closedb.php';} ?> Quote Link to comment https://forums.phpfreaks.com/topic/113262-alternating-rows-in-while-loop-help/ Share on other sites More sharing options...
mbradley Posted July 5, 2008 Author Share Posted July 5, 2008 Sorry to reply to myself but i thought this might help out others as well... the reason or well how i fixed it was i had bad .. well i put in the html link out of php and then went back to php... and that was BAD:) LOL for the while loop... so i added it in the loop as a echo and worked fine now and all the rows are displayed:) [move]FROM:[/move] echo "</center></td><td><center>"; ?> <a href="download.php?f=<?php echo $row[fname];?>'> <?php echo $row[fname]; echo "</a></center>"; [move]TOO:[/move] echo '</center></td><td><center>'; echo '<a href="download.php?f='; echo $row[fname]; echo '">'; echo $row[fname]; echo '</a></center>'; I hope that helps someone else... bc of the use of ( " ) in the html i used ( ' ) for the echo;) Quote Link to comment https://forums.phpfreaks.com/topic/113262-alternating-rows-in-while-loop-help/#findComment-582138 Share on other sites More sharing options...
wildteen88 Posted July 5, 2008 Share Posted July 5, 2008 You should have look into the concatenation operator to join strings. I'd change: echo '</center></td><td><center>'; echo '<a href="download.php?f='; echo $row[fname]; echo '">'; echo $row[fname]; echo '</a></center>'; to echo '</center></td><td><center><a href="download.php?f=' . $row['fname']} . '">' . $row['fname'] . '</a></center>'; Quote Link to comment https://forums.phpfreaks.com/topic/113262-alternating-rows-in-while-loop-help/#findComment-582174 Share on other sites More sharing options...
mbradley Posted July 5, 2008 Author Share Posted July 5, 2008 yea i might do that but not that long bc i do have to keep it reasable to me:) there is a long thing b4 and after that:) so i wanted to keep it seperate to a point so i can edit and modify it for later use Quote Link to comment https://forums.phpfreaks.com/topic/113262-alternating-rows-in-while-loop-help/#findComment-582485 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.