Jump to content

pocobueno1388

Members
  • Posts

    3,369
  • Joined

  • Last visited

    Never

Everything posted by pocobueno1388

  1. Why do you have a period in front of the dollar sign? $.number
  2. This line for ($i=3; $i<100; $i+=2){ Is telling $i to start at 3, increase by 2 each time the loop runs, and to run the loop 99 times (since you want all odd numbers up to 99. if ($cols == 5){ echo '<tr>'; $cols = 0; } I set up a counter named $cols, this counts how many times the loop has run...so if it has run 5 times, then $cols equals 5. So that code checks if the loop has run 5 times, and if it has, to create a new row (since you want 5 numbers per line). Then it starts the counter over for the next row. Hopefully those make sense
  3. <?php echo '<table border=1>'; $cols = 1; for ($i=3; $i<100; $i+=2){ echo '<td>'.$i.'</td>'; if ($cols == 5){ echo '<tr>'; $cols = 0; } $cols++; } echo '</table>'; ?>
  4. Try this, and tell us what it gives you <?php $query =" INSERT INTO tbl_auth_user ( user_name, user_password, Home page, Ryedale Rumble, Latest Results, National Road Race Championship, Board, Events Workgroup, Development, WRYL, Majour Events, News) VALUES ( '$User', 'PASSWORD(Password)', '$Home', '$Ryedale', '$Latest', '$NRRC', '$Board', '$Events', '$Development', '$WRYL', '$Major', '$News')"; $result = mysql_query($query)or die(mysql_error()."<p>With Query<br>$query"); echo "<p>$query"; include 'closedb.php'; ?>
  5. How about this? <?php echo '<table border=1>'; for ($i=3; $i<100; $i+=2){ echo '<tr>'; echo '<td>'.$i.'</td>'; echo '</tr>'; } echo '</table>'; ?>
  6. Well, I gave you the code to generate the numbers...now all you have to do is generate the HTML you want. If you don't know how to do that, then give a description of how you want the table to look.
  7. <?php if (isset($_POST['submit'])){ //get the color they chose $color = $_POST['color']; //set the cookie setcookie("color", $color, time()+86400); /* expire in 24 hours */ } //Set the backround color to whatever they chose, or the default if (isset($_COOKIE['color'])) echo "<body bgcolor='{$_COOKIE['color']}'>"; else echo "<body bgcolor='white'>"; ?> <form method="post"> <select name="color"> <option value="FF8C00">Orange</option> <option value="734A12">Brown</option> </select><br> <input type="submit" name="submit"> </form> If you want more information on cookies and how to use them http://us2.php.net/set_cookie
  8. A session ends when they close their browser, so it would last the entire time they are on your site...but next time they came to your site (after the browser was closed) they would have to do it over again. A cookie is almost like a session, but lasts longer. It lasts until the user clears them, or it times out. If you store it in a database, the color will be there forever or until changed. That would only work if you had registered users though, so you could tell who was who.
  9. You would just change your query up a bit, like this SELECT * FROM users WHERE userid > 0 ORDER BY rand()
  10. Yes, there is a way. From you description, it sounds like you want this to immediately happen...which can be done with JavaScript. If you just want them to select a background color and have that color display after they click a submit button, then you can use PHP. Depending on how long you want the color to stick, you can use a database (long lasting), a session (short lasting), or a cookie (in between). You would just store the color using one of those methods.
  11. If you want to display random, there is no need to do all that extra work with PHP, you can do it right in your query SELECT * FROM users ORDER BY rand() That will make the results from the database come back random. If you want to sort it by pages, look into pagination.
  12. If you tell us what your trying to accomplish, I'm sure we can show you the best way to do it =] But yes, you can do something like this <?php $i = 1; $i +=3; echo $numbers[$i]; //will print out as $numbers[4] ?>
  13. Your calling your function before you even create it. Try changing your scripts to this 1st script <?php header('Content-type: image/jpeg'); $link = $_GET['link']; $x_max = $_GET['x_max']; // open photo function open_photo ($temp_photo) { # JPEG: $im = @imagecreatefromjpeg($temp_photo); if ($im !== false) { return $im; } # GIF: $im = @imagecreatefromgif($temp_photo); if ($im !== false) { return $im; } # PNG: $im = @imagecreatefrompng($temp_photo); if ($im !== false) { return $im; } # GD: $im = @imagecreatefromgd($temp_photo); if ($im !== false) { return $im; } # GD2: $im = @imagecreatefromgd2($temp_photo); if ($im !== false) { return $im; } # WBMP: $im = @imagecreatefromwbmp($temp_photo); if ($im !== false) { return $im; } # XBM: $im = @imagecreatefromxbm($temp_photo); if ($im !== false) { return $im; } # XPM: $im = @imagecreatefromxpm($temp_photo); if ($im !== false) { return $im; } # ? $im = @imagecreatefromstring(file_get_contents($temp_photo)); if ($im !== false) { return $im; } return false; } // function call $photo_fun = open_photo ( $link ); // get size $x = imagesx($photo_fun); $y = imagesy($photo_fun); $y_max = $y * ($x_max/$x); // change size $change_size = imagecreatetruecolor($x_max, $y_max); imagecopyresampled($change_size, $photo_fun, 0, 0, 0, 0, $x_max, $y_max, $x, $y); // text color $white_color = imagecolorallocate($change_size, 255, 255, 255); // add text to photo imagestring($change_size, 3, 5, imagesy($change_size)-20, 'www.............com', $white_color); imagejpeg($change_size) ; ?> 2nd script <?php header('Content-type: image/jpeg'); $link = $_GET['link']; $x_max = $_GET['x_max']; // open photo function open_photo ($temp_photo) { # JPEG: $im = @imagecreatefromjpeg($temp_photo); if ($im !== false) { return $im; } # GIF: $im = @imagecreatefromgif($temp_photo); if ($im !== false) { return $im; } # PNG: $im = @imagecreatefrompng($temp_photo); if ($im !== false) { return $im; } # GD: $im = @imagecreatefromgd($temp_photo); if ($im !== false) { return $im; } # GD2: $im = @imagecreatefromgd2($temp_photo); if ($im !== false) { return $im; } # WBMP: $im = @imagecreatefromwbmp($temp_photo); if ($im !== false) { return $im; } # XBM: $im = @imagecreatefromxbm($temp_photo); if ($im !== false) { return $im; } # XPM: $im = @imagecreatefromxpm($temp_photo); if ($im !== false) { return $im; } # ? $im = @imagecreatefromstring(file_get_contents($temp_photo)); if ($im !== false) { return $im; } return false; } // function call $photo_fun = open_photo ( $link ); // get size $x = imagesx($photo_fun); $y = imagesy($photo_fun); $y_max = $y * ($x_max/$x); // change size $change_size = imagecreatetruecolor($x_max, $y_max); imagecopyresampled($change_size, $photo_fun, 0, 0, 0, 0, $x_max, $y_max, $x, $y); imagejpeg($change_size) ; ?>
  14. The numbers are all stored in the $numbers array. echo $numbers[0]; Will print out the first number in the array. $number[1] will print out the second, and so on. Is that what you want? I guess it depends on what your wanting to do.
  15. I would just search Google, I can't think of any particular one thats better than the rest of them
  16. It would be something like this <?php if (isset($_POST['submit'])){ //check if they checked that they have a pavilion if (isset($_POST['pavilion'])){ //update the database with "yes" $query = mysql_query("UPDATE table SET pavilion='yes' WHERE pavilion='{$_POST['pavilion']}'")or die(mysql_error()); } } //check the databse to figure out if the field should be checked $query = mysql_query("SELECT pavilion FROM table WHERE pavilion='$pavilion'")or die(mysql_error()); $row = mysql_fetch_assoc($query); if ($row['pavilion'] == 'yes') $checked = "checked='yes'"; else $checked = ""; ?> <form method="post"> <input type="checkbox" name="pavilion" value="<?=$pavilion?>" <?=$checked?>/><br> <input type="submit" name="submit"> </form> Just edit the database information and see if it works for you.
  17. Yeah, thats true. So you really don't need to check if it's empty....unless they want a separate error for some reason.
  18. The same way you have been doing it. Here is how you would do the email format check. <?php if ($_POST['email']=='') $arrErrors['email'] = 'A valid email address is required.'; if (!preg_match("/^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$/", $_POST['email'])) $arrErrors['email_format'] = 'A valid email format is required.'; ?>
  19. To check if an email is a valid format <?php if (preg_match("/^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$/", $email)) { echo "Valid"; } else { echo "Invalid"; } ?> To check if something is numeric <?php if (is_numeric($num)){ echo "valid"; } else { echo "not valid"; } ?> Check for only letters <?php if (preg_match("[A-Za-z]", $string)) { echo "Valid"; } else { echo "Invalid"; } ?>
  20. In my opinion OOP is a more advanced part of PHP, so it's a plus in my book. I would personally take someone more serious if they did a large project in OOP rather than procedural code if it was necessary.
  21. Like this <?php $num = 1; while ($row = mysql_fetch_assoc($query)){ echo $num.' '.$row['col'].'<br>'; $num++; } ?>
  22. OOP has a lot of advantages. Procedural code is written more quickly and processes quicker, but OOP is much more organized, maintainable, and easy to extend on. You can also reuse classes with very little to no editing. So if your coding something that you know you can reuse over and over in the future, it would definitely be worth using OOP for it.
  23. You need to do a CHECK first to see if they requested the data. I assume you have a submit button, we will call that "submit". So you would just check if they pressed the button <?php if (isset($_POST['submit'])){ //now put all the code here } ?>
×
×
  • 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.