Jump to content

pocobueno1388

Members
  • Posts

    3,369
  • Joined

  • Last visited

    Never

Everything posted by pocobueno1388

  1. As for the query, it would be like this SELECT * FROM table WHERE field LIKE '%value%' I'm not going to comment on your first question as I don't know a ton about it. I believe you are correct though.
  2. You need to be calling session_start() at the beginning of your pages. Please use [.code][./code] tags next time, without the dots.
  3. I'm gonna have to agree with Neon. It is very dull looking, and is just about the same as the old one. It just doesn't have a "professional" look to it.
  4. Yes, you are doing it correctly...just to make sure, here is an example. <?php $query = "SELECT col FROM table WHERE"; if (isset($gender)) $query .= " AND gender='$gender'"; if (isset($country)) $query .= " AND country='$country'"; //...and so on ?>
  5. You could use the PHP function wordwrap() http://us.php.net/wordwrap
  6. Is there some sort of pattern to the numbers to where they should display? I don't understand how you got 4.1 should be printed on row 7 col 10.
  7. Here, read more about it here: http://us2.php.net/mysql_error It gives you the actual error, most of the times. If you spelled a field name wrong, it will tell you that the field doesn't exist. Sometimes it will give you a resource error...it just all depends.
  8. What are you using a debugger for? You know you can put a die statement at the end of your queries to catch errors, right? $result = mysql_query($query)or die(mysql_error());
  9. Try putting quotes around "gone" setcookie(ID_my_site, 'gone', $past); setcookie(Key_my_site, 'gone', $past);
  10. Well...you are using more if statements than you need to, you only need one since you are doing the same thing for each one. <?php if ($row['title'] == '1.1' || $row['title'] == '1.2' || $row['title'] == '2.1' || $row['title'] == '2.2' || ...and so on){ echo $row['description']; } ?>
  11. There is something wrong with your insert query. Change $sql="INSERT INTO $tbl_name(confirm_code, name, address, address1, address2, address3, address4, country, zip, telephone, email, username, password)VALUES('$confirm_code', '$name', '$address', '$address1', '$address2','$address3', '$address4','$country' ,'$zip', '$telephone', '$email', '$username', '$password',)"; $result=mysql_query($sql); To $sql="INSERT INTO $tbl_name(confirm_code, name, address, address1, address2, address3, address4, country, zip, telephone, email, username, password)VALUES('$confirm_code', '$name', '$address', '$address1', '$address2','$address3', '$address4','$country' ,'$zip', '$telephone', '$email', '$username', '$password')"; $result=mysql_query($sql)or die(mysql_error()); Tell us what it outputs.
  12. Where are you getting the variable $c?
  13. First do a query to check if the value is the same, then if it isn't, do the update. Yes...this would take an extra query, but it's necessary and really isn't that much to handle.
  14. That is for OOP. http://www.phpfreaks.com/forums/index.php/topic,95867.0.html
  15. Just use LIMIT in your query. If you wanted ONLY results 3-5 you would do this: <?php $query1 = mysql_query("SELECT * FROM news LIMIT 3,5"); ?>
  16. You were just using way more queries than you had to. When you got this error Table 'rpg.users' doesn't exist Thats pretty straight-forward that I accidentally made your table name "user" plural. With your original code, all you had to do was add the two rows up...but even if you did that and it worked, the way you were doing it with all the queries isn't very efficient as you can see I gave you code that does in a lot less lines and is much easier on the database.
  17. <?php $query = "SELECT MAX(iduser) as max_user, SUM(bani) as max_bani, SUM(puncte) as max_puncte, (puncte + bani) as total FROM user GROUP BY iduser"; $result = mysql_query($query)or die(mysql_error()); $row = mysql_fetch_assoc($result); print<<<HERE Total membri: {$row['max_user']}<br> Total bani: {$row['max_bani']}<br> Total puncte: {$row['max_puncte']}<br> Total bani and puncte: {$row['total']} HERE; ?>
  18. Give this a try <?php $sql1 = "SELECT * FROM bes_optionals ORDER BY title ASC"; $show1 = @mysql_query($sql1,$connection) or die(mysql_error()); $cost = 0; while ($row1 = mysql_fetch_array($show1)) { if ($row1['type'] == 1) { if ($_GET[$row1['id']] == 1) { $cost += $row1['cost']; } } else if ($row1['type'] == 2) { if ($_GET[$row1['id']] == 1) { $cost += $row1['cost']; } else if ($_GET[$row1['id']] == 2) { $cost += $row1['cost']*2; } else if ($_GET[$row1['id']] == 3) { $cost += $row1['cost']*3; } else if ($_GET[$row1['id']] == 4) { $cost += $row1['cost']*4; } } } echo "Total: " . $cost; ?>
  19. You could do that all in one query <?php $query = "SELECT MAX(iduser) as max_user, SUM(bani) as max_bani, SUM(puncte) as max_puncte, (puncte + bani) as total FROM users"; $result = mysql_query($query)or die(mysql_error()); $row = mysql_fetch_assoc($result); print<<<HERE Total membri: {$row['max_user']}<br> Total bani: {$row['max_bani']}<br> Total puncte: {$row['max_puncte']}<br> Total bani and puncte: {$row['total']} HERE; ?>
  20. Your not real clear on what your trying to do. It sounds like you may be looking for "pagination", so try googling that. Also, the for loop inside of your while loop doesn't look like it's needed.
  21. <?php $query = mysql_query("SELECT SUM(blah) as sum FROM table_name"); $row = mysql_fetch_assoc($query)or die(mysql_error()); echo $row['sum']; //will print out sum ?>
  22. Yes, you would need to use sessions, cookies, or a database depending on how long you want the items to stay in the cart.
  23. From your vague explanation, it doesn't sound like it would be anything too difficult...although that also depends on your experience level with PHP and MySQL. If you are still a novice with programming, I would suggest posting this in the freelancing forum or a freelancing site, or keep practicing until you are able to complete the project. Again, depending on your experience, pushing you in the right direction my not be easy, and someone isn't just going to write the code for you.
  24. Give this a try <?php $query = "SELECT DISTINCT year as year, mid_final AS mf FROM student_score WHERE student_id = $s_id ORDER BY year ASC"; $result = @mysql_query($query); if ($result) { if (mysql_num_rows($result) > 0){ while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo '<p align="left"><a href="editStudentScore.php?student_id=' . $s_id . '&year=' . $row['year'] . '&midterm_final=' . $row['mf'] . '">Edit year ' . $row['year'] .' and term ' . $row['mf'] . '</a></p>'; echo '<br /><br />'; } } else { echo "No Results Found"; } } ?>
×
×
  • 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.