sylunt1 Posted December 31, 2007 Share Posted December 31, 2007 I have been banging my head on this for hours... I am sure it is something stupid, but I can't find it. I would appreciate it if someone could find the loop here and see what's going on... <?php include 'C:\Domains\syluntspace.com\wwwroot\vmware\inc\my.php'; $db = mysql_connect("$server", "$user", "$password"); mysql_select_db('mentor', $db) or die ('Cannot connect to $db_Database : ' . mysql_error()); $tse_id = $_GET['id']; $result = mysql_query ("SELECT DATE_FORMAT(tse.tse_start, '%M %d, %Y') AS tse_start1, tse.tse_id, tse.tse_name, tse.tse_mentorname, tse.tse_mgr, tse.tse_grpid, DATE_FORMAT(tse.tse_vi3, '%M %d, %Y') AS tse_vi31, DATE_FORMAT(tse.tse_estlive, '%M %d, %Y') AS tse_estlive1, DATE_FORMAT(tse.tse_golive, '%M %d, %Y') AS tse_golive1, DATE_FORMAT(tse.tse_vcp, '%M %d, %Y') AS tse_vcp1, tse.tse_vcpver, tse.tse_ismentor, tse.tse_ismgr, tse.tse_level, tse.tse_weekorder, tse.tse_bootdone, sme.sme_id, sme.sme_name, mgmt.mgmt_id, mgmt.mgmt_name FROM tse, sme, mgmt, weeks, weekorder WHERE $id = tse.tse_id and sme.sme_id = tse.tse_grpid and mgmt.mgmt_id = tse.tse_mgr") or die(mysql_error()); while($row = mysql_fetch_array($result)) { $tse_id = $row['tse_id']; $tse_name = $row['tse_name']; $tse_mentorname = $row['tse_mentorname']; $tse_mgr = $row['tse_mgr']; $tse_grpid = $row['tse_grpid']; $tse_start = $row['tse_start1']; $tse_vi3 = $row['tse_vi3']; $tse_estlive = $row['tse_estlive1']; $tse_golive = $row['tse_golive1']; $tse_vcp = $row['tse_vcp1']; $tse_vcpver = $row['tse_vcpver']; $tse_ismentor = $row['tse_ismentor']; $tse_ismgr = $row['tse_ismgr']; $tse_level = $row['tse_level']; $tse_weekorder = $row['tse_weekorder']; $tse_bootdone = $row['tse_bootdone']; $sme_id = $row['sme_id']; $sme_name = $row['sme_name']; $mgmt_id = $row['mgmt_id']; $mgmt_name = $row['mgmt_name']; echo '<table width="90%" cellspacing="1" cellpadding="1" border="0"> <tr><td width="20%" height="1"><b>TSE Name:</b></td><td width="20%" height="1">' . $tse_name . '</td><td width="70%" height="1"></td></tr> <tr><td width="20%" height="1"><b>Mentor:</b></td><td width="20%" height="1">' . $tse_mentorname . '</td><td width="70%" height="1"></td></tr> <tr><td width="20%" height="1"><b>Manager:</b></td><td width="20%" height="1">' . $mgmt_name . '</td><td width="70%" height="1"></td></tr> <tr><td width="20%" height="1"><b>Group:</b></td><td width="20%" height="1">' . $sme_name . '</td><td width="70%" height="1"></td></tr> <tr><td width="20%" height="1"><b>TSE Level:</b></td><td width="20%" height="1">' . $tse_level . '</td><td width="70%" height="1"></td></tr>'; if ($tse_ismentor == '1'){ echo '<tr><td width="20%" height="1"><b>TSE is a Mentor:</b></td><td width="20%" height="1"> Yes </td><td width="70%" height="1"></td></tr>'; } else{ echo '<tr><td width="20%" height="1"><b>TSE is a Mentor:</b></td><td width="20%" height="1"> No </td><td width="70%" height="1"></td></tr>'; } echo '<tr><td width="20%" height="1"><b>VI3 Class Date:</b></td><td width="20%" height="1">' . $tse_vi3 . '</td><td width="70%" height="1"></td></tr>'; if ($tse_bootdone == '1'){ echo '<tr><td width="20%" height="1"><b>Bootcamp Complete:</b></td><td width="20%" height="1"> Yes </td><td width="70%" height="1"></td></tr>'; } else{ echo '<tr><td width="20%" height="1"><b>Bootcamp Complete:</b></td><td width="20%" height="1"> No </td><td width="70%" height="1"></td></tr>'; } echo '<tr><td width="20%" height="1"><b>Est. Go Live Date:</b></td><td width="20%" height="1">' . $tse_estlive . '</td><td width="70%" height="1"></td></tr> <tr><td width="20%" height="1"><b>Go Live Date:</b></td><td width="20%" height="1">' . $tse_golive . '</td><td width="70%" height="1"></td></tr> <tr><td width="20%" height="1"><b>VCP Date:</b></td><td width="20%" height="1">' . $tse_vcp . '</td><td width="70%" height="1"></td></tr> <tr><td width="20%" height="1"><b>VCP Version:</b></td><td width="20%" height="1">' . $tse_vcpver . '</td><td width="70%" height="1"></td></tr></table>'; } ?> Thanks in advance, Chris Quote Link to comment https://forums.phpfreaks.com/topic/83873-find-my-loop/ Share on other sites More sharing options...
kenrbnsn Posted December 31, 2007 Share Posted December 31, 2007 Can you explain a little bit better what your problem is? Ken Quote Link to comment https://forums.phpfreaks.com/topic/83873-find-my-loop/#findComment-426838 Share on other sites More sharing options...
revraz Posted December 31, 2007 Share Posted December 31, 2007 You are not explaining the problem very well. But here's your loop while($row = mysql_fetch_array($result)) Quote Link to comment https://forums.phpfreaks.com/topic/83873-find-my-loop/#findComment-426839 Share on other sites More sharing options...
sasa Posted December 31, 2007 Share Posted December 31, 2007 $tse_id = $_GET['id']; // you define $tse_id $result = mysql_query ("SELECT DATE_FORMAT(tse.tse_start, '%M %d, %Y') AS tse_start1, tse.tse_id, tse.tse_name, tse.tse_mentorname, tse.tse_mgr, tse.tse_grpid, DATE_FORMAT(tse.tse_vi3, '%M %d, %Y') AS tse_vi31, DATE_FORMAT(tse.tse_estlive, '%M %d, %Y') AS tse_estlive1, DATE_FORMAT(tse.tse_golive, '%M %d, %Y') AS tse_golive1, DATE_FORMAT(tse.tse_vcp, '%M %d, %Y') AS tse_vcp1, tse.tse_vcpver, tse.tse_ismentor, tse.tse_ismgr, tse.tse_level, tse.tse_weekorder, tse.tse_bootdone, sme.sme_id, sme.sme_name, mgmt.mgmt_id, mgmt.mgmt_name FROM tse, sme, mgmt, weeks, weekorder WHERE $id = tse.tse_id and sme.sme_id = tse.tse_grpid and mgmt.mgmt_id = tse.tse_mgr") or die(mysql_error()); // you use $id in your query you use variable $id that is not set yet Quote Link to comment https://forums.phpfreaks.com/topic/83873-find-my-loop/#findComment-426964 Share on other sites More sharing options...
sylunt1 Posted January 2, 2008 Author Share Posted January 2, 2008 The problem is that instead of returning 1 set of values it repeats the same thing over and over again. I want one set of data - 1 time the $id comes from the previous page - that part works fine. I realize the loop starts here while($row = mysql_fetch_array($result)) - what I wanted to know was why it keeps repeating - where does it get stuck? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/83873-find-my-loop/#findComment-428201 Share on other sites More sharing options...
aschk Posted January 2, 2008 Share Posted January 2, 2008 Does your loop end? What do you result looks like? Have you tried simplifying it? <?php include 'C:\Domains\syluntspace.com\wwwroot\vmware\inc\my.php'; $db = mysql_connect("$server", "$user", "$password"); mysql_select_db('mentor', $db) or die ('Cannot connect to $db_Database : ' . mysql_error()); $tse_id = $_GET['id']; $result = mysql_query ("SELECT DATE_FORMAT(tse.tse_start, '%M %d, %Y') AS tse_start1, tse.tse_id, tse.tse_name, tse.tse_mentorname, tse.tse_mgr, tse.tse_grpid, DATE_FORMAT(tse.tse_vi3, '%M %d, %Y') AS tse_vi31, DATE_FORMAT(tse.tse_estlive, '%M %d, %Y') AS tse_estlive1, DATE_FORMAT(tse.tse_golive, '%M %d, %Y') AS tse_golive1, DATE_FORMAT(tse.tse_vcp, '%M %d, %Y') AS tse_vcp1, tse.tse_vcpver, tse.tse_ismentor, tse.tse_ismgr, tse.tse_level, tse.tse_weekorder, tse.tse_bootdone, sme.sme_id, sme.sme_name, mgmt.mgmt_id, mgmt.mgmt_name FROM tse, sme, mgmt, weeks, weekorder WHERE $id = tse.tse_id and sme.sme_id = tse.tse_grpid and mgmt.mgmt_id = tse.tse_mgr") or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo "<pre>"; print_r($row); echo "</pre>; } Also, what does your include accomplish? Nothing as far as I can see. What is in the file in question? Quote Link to comment https://forums.phpfreaks.com/topic/83873-find-my-loop/#findComment-428206 Share on other sites More sharing options...
sylunt1 Posted January 2, 2008 Author Share Posted January 2, 2008 the code you provided does the same thing.... repeats 16 times the result (my code) looks like this... TSE Name: tsename Mentor: mntname Manager: mgrname Group: Networking TSE Level: 1 TSE is a Mentor: No VI3 Class Date: Bootcamp Complete: Yes Est. Go Live Date: Go Live Date: VCP Date: VCP Version: 0.0 TSE Name: tsename Mentor: mntname Manager: mgrname Group: Networking TSE Level: 1 TSE is a Mentor: No VI3 Class Date: Bootcamp Complete: Yes Est. Go Live Date: Go Live Date: VCP Date: VCP Version: 0.0 TSE Name: tsename Mentor: mntname Manager: mgrname Group: Networking TSE Level: 1 TSE is a Mentor: No VI3 Class Date: Bootcamp Complete: Yes Est. Go Live Date: Go Live Date: VCP Date: VCP Version: 0.0 TSE Name: tsename Mentor: mntname Manager: mgrname Group: Networking TSE Level: 1 TSE is a Mentor: No VI3 Class Date: Bootcamp Complete: Yes Est. Go Live Date: Go Live Date: VCP Date: VCP Version: 0.0 TSE Name: tsename Mentor: mntname Manager: mgrname Group: Networking TSE Level: 1 TSE is a Mentor: No VI3 Class Date: Bootcamp Complete: Yes Est. Go Live Date: Go Live Date: VCP Date: VCP Version: 0.0 TSE Name: tsename Mentor: mntname Manager: mgrname Group: Networking TSE Level: 1 TSE is a Mentor: No VI3 Class Date: Bootcamp Complete: Yes Est. Go Live Date: Go Live Date: VCP Date: VCP Version: 0.0 TSE Name: tsename Mentor: mntname Manager: mgrname Group: Networking TSE Level: 1 TSE is a Mentor: No VI3 Class Date: Bootcamp Complete: Yes Est. Go Live Date: Go Live Date: VCP Date: VCP Version: 0.0 TSE Name: tsename Mentor: mntname Manager: mgrname Group: Networking TSE Level: 1 TSE is a Mentor: No VI3 Class Date: Bootcamp Complete: Yes Est. Go Live Date: Go Live Date: VCP Date: VCP Version: 0.0 TSE Name: tsename Mentor: mntname Manager: mgrname Group: Networking TSE Level: 1 TSE is a Mentor: No VI3 Class Date: Bootcamp Complete: Yes Est. Go Live Date: Go Live Date: VCP Date: VCP Version: 0.0 TSE Name: tsename Mentor: mntname Manager: mgrname Group: Networking TSE Level: 1 TSE is a Mentor: No VI3 Class Date: Bootcamp Complete: Yes Est. Go Live Date: Go Live Date: VCP Date: VCP Version: 0.0 TSE Name: tsename Mentor: mntname Manager: mgrname Group: Networking TSE Level: 1 TSE is a Mentor: No VI3 Class Date: Bootcamp Complete: Yes Est. Go Live Date: Go Live Date: VCP Date: VCP Version: 0.0 TSE Name: tsename Mentor: mntname Manager: mgrname Group: Networking TSE Level: 1 TSE is a Mentor: No VI3 Class Date: Bootcamp Complete: Yes Est. Go Live Date: Go Live Date: VCP Date: VCP Version: 0.0 TSE Name: tsename Mentor: mntname Manager: mgrname Group: Networking TSE Level: 1 TSE is a Mentor: No VI3 Class Date: Bootcamp Complete: Yes Est. Go Live Date: Go Live Date: VCP Date: VCP Version: 0.0 TSE Name: tsename Mentor: mntname Manager: mgrname Group: Networking TSE Level: 1 TSE is a Mentor: No VI3 Class Date: Bootcamp Complete: Yes Est. Go Live Date: Go Live Date: VCP Date: VCP Version: 0.0 TSE Name: tsename Mentor: mntname Manager: mgrname Group: Networking TSE Level: 1 TSE is a Mentor: No VI3 Class Date: Bootcamp Complete: Yes Est. Go Live Date: Go Live Date: VCP Date: VCP Version: 0.0 TSE Name: tsename Mentor: mntname Manager: mgrname Group: Networking TSE Level: 1 TSE is a Mentor: No VI3 Class Date: Bootcamp Complete: Yes Est. Go Live Date: Go Live Date: VCP Date: VCP Version: 0.0 Quote Link to comment https://forums.phpfreaks.com/topic/83873-find-my-loop/#findComment-428313 Share on other sites More sharing options...
kenrbnsn Posted January 2, 2008 Share Posted January 2, 2008 If you're only expecting one record to be returned, why are you using a while statement? Just use a single fetch. Ken Quote Link to comment https://forums.phpfreaks.com/topic/83873-find-my-loop/#findComment-428314 Share on other sites More sharing options...
sylunt1 Posted January 2, 2008 Author Share Posted January 2, 2008 OH MAN... well I found it - the weeks, weekorder in the FROM section jacked it up... took those out and it is fixed. Solved my own problem - thanks all Quote Link to comment https://forums.phpfreaks.com/topic/83873-find-my-loop/#findComment-428333 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.