Jump to content

falcon1620

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

falcon1620's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the tip. Yea I actually that is very helpful separating the Query from the MySQL function just because I could get the output of the SQL query and run it against my SQL server to debug it. I don't know why I like to squeeze those together. So I went ahead and added a print_r ($r) statement, and the same deal, during executing of the for loop, the $r returns the array with information in the array, and the while loop returns nothing. So I went ahead and re-tried the function and found a stray ; ending my while loop prematurely that I think came about while I was forwarding my Eclipse IDE over SSH during a "moment", so the line looked something like this HILARIOUS! 2 days later.... Coding on a 15" dell LCD... LOL Some one must have been messing with me on that one.
  2. Ok so I have a simple database table set up, and I am trying to get the results into an HTML table, however I have a question. One loop I write in a for loop will dump the data I want to the table, the other returns no results. For example I have the code... //SQL Lookup //SQL Lookup $sqlAppt = mysql_query("SELECT * FROM Appointment WHERE TTUNumber = \"$TTUNumber\" && ShippingNumber = \"$ShippingNumber\" LIMIT 1") or die('Could not execute SQL statement ' . mysql_error()); $numbRows = mysql_num_rows($sqlAppt); echo "<p>Number of rows found: $numbRows </p>\n"; So When I create the first whlile loop, i do not get any results from my database. while($r=mysql_fetch_array($sqlAppt)){ $ApptDate=$r['Date']; $ApptTime=$r['Time']; $ApptNumber=$r['ApptNumber']; $ApptDock=$r['Dock']; echo '<h1>I got here</h1>'."\n"; echo "<table>\n"; echo "<tr><td>Date</td><td>$ApptDate</td></tr>\n"; echo "<tr><td>Time</td><td>$ApptTime</td></tr>\n"; echo "<tr><td>Appt Number</td><td>$ApptNumber</td></tr>\n"; echo "<tr><td>Dock</td><td>$ApptDock</td></tr>\n"; echo "</table>\n"; } The Results is this: However, when I create a different loop structure... for($i = 0; $i < $numbRows; $i++) { $r=mysql_fetch_array($sqlAppt); $ApptDate=$r['Date']; $ApptTime=$r['Time']; $ApptNumber=$r['ApptNumber']; $ApptDock=$r['Dock']; echo '<h1>I got here</h1>'."\n"; echo "<table>\n"; echo "<tr><td>i:</td><td>$i</td></tr>\n"; echo "<tr><td>Date</td><td>$ApptDate</td></tr>\n"; echo "<tr><td>Time</td><td>$ApptTime</td></tr>\n"; echo "<tr><td>Appt Number</td><td>$ApptNumber</td></tr>\n"; echo "<tr><td>Dock</td><td>$ApptDock</td></tr>\n"; echo "</table>\n"; } Naturally I get a different result! I can't figure out why for the life of me that my while loop would not return anything on here>? Does anyone have any idea's? Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.