Jump to content

xtopolis

Members
  • Posts

    1,422
  • Joined

Everything posted by xtopolis

  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).
  15. Shouldn't you be checking the value of $_POST['requests'] instead of $_SESSION['checkbox']? From the code you gave us, all I can tell is that in your logic, you are looking at a session variable, but your above code is dealing with a form. Is that it?
  16. Yes - I don't see any reason why you wouldn't be able to do that. Syntactically, it seems fine. edit: You edited it while I was replying.. , but in the version I saw later you're missing a ) to match the empty( function. (2nd if statement)
  17. Yes - for simple things, you might just have it modify a file like (requests.ini) and have PHP read the contents of that file at set intervals. However, if there are going to be multiple DJs, etc, etc, you may switch to using a database for statistical considerations later down the line.
  18. I've seen what you're talking about, and there are various ways to do this, so I'll speak in general terms. If you have a specific example, you could investigate the source code yourself, or link it here and nicely ask someone to break down the "technologies" used. In general, to display one "website" as a subpage of another: You can use frames/iframes. //not very widely used You can use javascript(ajax) and divs. //more common I'm not 100% on the technologies, but I think they either load the page in another div, or even use javascript injection into the destination page.
  19. From the information you've given us, storing the two templates inline in the same PHP file would be fine. Adding a database or fileloading (require/include) would likely be more overhead than needed, assuming your template is a fairly small amount of code. If you're talking about saving the "requests turned on/off" thing.. that's a slightly different story. You could probably get away with it by using sessions and having the client pages check on intervals to see whether or not to display the template. Does that answer your question, or are you referring to something else?
  20. You're using a combination of a literal string and concatenation incorrectly. <?php if ($_POST['hid']==0) { header("Location: sample.php?aid=" . $aid); } ?> or <?php if ($_POST['hid']==0) { header('Location: sample.php?aid=' . $aid); } ?> Your method echos text of $aid rather than the value of the variable $aid I'm assuming.
  21. My personal preference, which I've found to be easier is to surround echo strings with double quotes, and then attributes within those strings with single quotes. Only when working with Javascript inside those strings will I use escaped double quotes (\") around the outside. <?php if (isset($_SESSION['idx'])) { echo "<div class='containerheader' id='titleTextImg'><strong>Military Attachés accredited in Egypt</strong>"; echo "<a id='imageDivLink8' href=\"javascript:toggle5('contentDivImg8', 'imageDivLink8');\"><img src='images/x.gif' align='right'></a></div>"; echo "<div class='container' id='contentDivImg8' style='font-size:15px; display:block; margin-bottom:5px;'> <a href='member_countries.php'><img src='images/worldmap.gif' width='300' height='184' alt='Member Countries' title='Member Countries' border='0' /></a> <br /><span style='font-size:12px;'>Click somewhere on the map to open the member countries page.</span></div><br />";} ?>
  22. <?php echo "<a href='#' onclick='return false' onmousedown=\"javascript:SlideBox('what10');\">"; ?>
  23. This example might get you some of the way there, but I don't have time to read up on the GD library right now. Hopefully this might get you a little closer to your answer. This is probably not the best way; I'm just trying to get it to work in general. <?php $body = imagecreatefrompng('body.png'); $head = imagecreatefrompng('head.png'); $armour = imagecreatefrompng('armour.png'); //innermost->outermost imagecopymerge($head, $body, 0, 0, 0, 0, 64, 102, 100); imagecopymerge($armour, $head, 0, 0, 0, 0, 64, 102, 100); header('Content-Type: image/png'); imagepng($armour); //last image used //cleanup imagedestroy($body); imagedestroy($head); imagedestroy($armour); ?> If there are a reasonably finite number of combinations, I would recommend you generate them ahead of time, and just access the based on a mask of some sort.
×
×
  • 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.