Jump to content

xtopolis

Members
  • Posts

    1,422
  • Joined

Profile Information

  • Gender
    Male
  • Location
    CA, USA

xtopolis's Achievements

Member

Member (2/5)

0

Reputation

  1. So, there were a few things missing with you code. Mainly, the while loop didn't have {} braces, and also it was freeing the mysqli result after the first iteration due to that. Here's your code cleanup and formatted in a way I prefer (I had trouble looking at your formatting, but that's just a personal thing). <br /> <a href='index.php'> Back Home </a> <br /> <br /> <?php // -------------------------- Connect to DB include ('connect_script.php'); // ------------------------------ Color variable for alternating table colors $color = 1; // ------------------------- Query Parameters $select = "SELECT (number) AS id, (first_name) AS fn, (last_name) AS ln, (position) AS position FROM table WHERE position = 'X' "; $get = @mysqli_query ($dbc, $select); // ------------------------- Run Query if($get) { // ------------------------Start table echo " <div style='border-style: solid;'> <table align='left' border='1'> <tr> <td>People</td> </tr> <tr> <td>ID</td><td>First Name</td><td>Last Name</td><td>Position</td> </tr>"; // ------------------------ Retrieve People while ($row = mysqli_fetch_array($get, MYSQLI_ASSOC)) { if($color==1) { echo ' <tr bgcolor= #47EA7D> <td>' . $row['id'] . '</td><td>' . $row['fn'] . '</td><td>' . $row['ln'] . '</td><td>' . $row['position'] . '</td> </tr>'; $color = '2'; }else{ echo ' <tr bgcolor= #A4C8B0> <td>' . $row['id'] . '</td><td>' . $row['fn'] . '</td><td>' . $row['ln'] . '</td><td>' . $row['position'] . '</td> </tr> '; $color= '1'; } }//end while loop // ----------------------- Close table echo "</div> </table>"; mysqli_free_result ($get); }//"get" (mysql query) if statement // -------------------- IF ERROR WITH QUERY else { echo "Didn't connect"; } // ---------------------- Spaces --> This is the code that doesn't appear to affect the space at the bottom of the table echo "<br /> <br /> <br />"; ?> ^^--- will this code work? I don't know. If an error exists after you add the while {} braces, then it's with the mysql connection/query. I made a sample array and it "worked" as far as I could tell what you were trying to do. I didn't see anything in here about a second table though. Here's the code I tested with. <?php error_reporting(E_ALL); echo "<br /> <a href='index.php'> Back Home </a> <br /> <br />"; // -------------------------- Connect to DB //include ('connect_script.php'); // ------------------------------ Color variable for alternating table colors $color = 1; // ------------------------- Query Parameters //$select = "SELECT (number) AS id, (first_name) AS fn, (last_name) AS ln, (position) AS position FROM table WHERE position = 'X' "; //$get = @mysqli_query ($dbc, $select); $row = array( "id" => range(0,25), "fn" => range("A","Z"), "ln" => range("z","a"), "position" => range(50,75) ); $get = true; // ------------------------- Run Query if ($get) { // ------------------------Start table echo " <div style='border-style: solid;'> <table align='left' border='1'> <tr> <td>People</td> </tr> <tr> <td>ID</td><td>First Name</td><td>Last Name</td><td>Position</td> </tr>"; // ------------------------ Retrieve People $counter = 0; while ($counter < 26) {//$row = mysqli_fetch_array($get, MYSQLI_ASSOC)) if ($color==1) {echo ' <tr bgcolor= #47EA7D> <td>' . $row['id'][$counter] . '</td><td>' . $row['fn'][$counter] . '</td><td>' . $row['ln'][$counter] . '</td><td>' . $row['position'][$counter] . '</td> </tr>'; $color = '2';} else {echo ' <tr bgcolor= #A4C8B0> <td>' . $row['id'][$counter] . '</td><td>' . $row['fn'][$counter] . '</td><td>' . $row['ln'][$counter] . '</td><td>' . $row['position'][$counter] . '</td> </tr> '; $color= '1';} // ----------------------- Close table $counter++; } echo "</div> </table>"; //mysqli_free_result ($get); } // -------------------- IF ERROR WITH QUERY else {echo "Didn't connect";} // ---------------------- Spaces --> This is the code that doesn't appear to affect the space at the bottom of the table echo "<br /> <br /> <br />"; ?>
  2. You overwrote your own function name: function Validate() { change it back.
  3. $errors = array();//empty array function Validate() { if($x = 1) { $errors[] = "X can't equal one"; } if($y = "cat") { $errors[] = "Meow"; } return $errors; } //check if validate is empty/null/whatever and show errors if they exist
  4. In ValidateForm() you return from the function as soon as the first condition is evaluated, regardless of what happens. I think you intended do something like this pseudocode: if (condition) true: push error into $errors array false: (nothing) if (othercondition) true: push error into $errors array false: (nothing) return $errors array
  5. "var" is a reserved word in Javascript. The function itself should be surrounded by double quotes (escaped ones for your string). <script type="text/javascript"> function popup(v) { alert(v); } </script> <?php $calendar.= "<td class='calendar-day'><div style='position:relative;height:100px;border:1px solid black;' onclick=\"popup('hello')\">"; ?>
  6. http://php.net/manual/en/function.exif-read-data.php ?
  7. date(String $format, [int $timestamp]); so probably something like: $time = date("F j, Y, g:i a", $_SERVER['REQUEST_TIME']); Though I think most people just do date("format", now()); where format is how you have it above. Test it out and see which gives you what you want.
  8. It is working correctly. You want to take that integer value and format it to your specs probably using the date function
  9. Ok Works in chrome 14.0.835.202 m Works in IE: 9.0.8112.16421 by clicking that link you sent me. The fact that that works scares me.
  10. It's probably logging you in based on cookies, not that link.
  11. ! try it and find out. it seems ok for me, but I don't have time to test it.
  12. Check the server itself, run a current time command. Narrow down the problem. It's either incorrect server time, or a daylight savings setting or something I'm guessing.
  13. The server may be in a different timezone than yourself.
  14. >= "There's your problem" for (expr1; expr2; expr3) statement The first expression (expr1) is evaluated (executed) once unconditionally at the beginning of the loop. In the beginning of each iteration, expr2 is evaluated. If it evaluates to TRUE, the loop continues and the nested statement(s) are executed. If it evaluates to FALSE, the execution of the loop ends. At the end of each iteration, expr3 is evaluated (executed).
×
×
  • 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.