Jump to content

triphis

Members
  • Posts

    62
  • Joined

  • Last visited

    Never

Everything posted by triphis

  1. ummm, you can store the URLS to the PDF files, and assign them id numbers or something check around phpfreaks.com for basic MySQL/PHP tutorials.
  2. Okay, I have a MySQL table, used to keep track of items I have in a collection. When I add a new item to my collection, I go to the \"add.php\" page: [php:1:3d60dc8dc8]<?php $q=\"SELECT * FROM r99 WHERE have=0 ORDER BY name ASC\"; $result = mysql_query($q,$db); while ($row = mysql_fetch_array($result)) { $name = $row[\"name\"]; ?> <form action=\"form.php?name=<?=$name?>\" method=\"post\"> <table width=300 border=0> <tr> <td width=\"150\"><font face=\"verdana\" size=\"1\"><?=$name?></td> <td><input type=\"text\" name=\"paid\" size=15></td> <td> <input type=\"submit\" name=\"submit\" value=\"Go!\"> </td> </tr></table><br></form> <?php } ?> [/php:1:3d60dc8dc8] This is sent to the form.php page like this: form.php?name=$name [php:1:3d60dc8dc8]<?php $connection = mysql_connect(\"$hostname\" , \"$user\" , \"$pass\"); $db = mysql_select_db($dbase , $connection); $q=\"UPDATE r99 SET have=\'1\' WHERE name=\'$name\'\"; $result= mysql_query($q, $connection) or die (\"Could not execute query : $q.\" . mysql_error()); mysql_free_result() $q=\"UPDATE r99 SET paid=\'$paid\' WHERE name=\'$name\'\"; $result= mysql_query($q, $connection) or die (\"Could not execute query : $q.\" . mysql_error()); mysql_free_result() ?>[/php:1:3d60dc8dc8] If you notice, the add php calls up items with HAVE=0 meaning I do not have it. Once it goes through the form page, it is set to 1 (so it won\'t appear on the add.php page again), and the price is added (which was formerly 0) I get this error : Parse error: parse error in /data/members/free/tripod/uk/t/r/i/triphis/htdocs/form.php on line 17 --- which refers to [php:1:3d60dc8dc8]$q=\"UPDATE r99 SET paid=\'$paid\' WHERE name=\'$name\'\";[/php:1:3d60dc8dc8] Where have I gone wrong? Thanx
  3. Hey, if I wanted to shorten this: [php:1:d805344b15]<?php if ($sort == \"name\") { $query = mysql_query(\"select user_id, user_name, user_address, user_type from table ORDER BY user_name\"); } elseif ($sort == \"address\") { $query = mysql_query(\"select user_id, user_name, user_address, user_type from table ORDER BY user_address\"); } elseif ($sort == \"type\") { $query = mysql_query(\"select user_id, user_name, user_address, user_type from table ORDER BY user_type\"); } else { $query = mysql_query(\"select user_id, user_name, user_address, user_type from table ORDER BY user_id\"); } ?>[/php:1:d805344b15] I could go like this right? : [php:1:d805344b15] $query = mysql_query(\"select user_id, user_name, user_address, user_type from table \"); if ($sort == \"name\") { $query .= ORDER BY user_name; } elseif ($sort == \"address\") { $query .= ORDER BY user_address; } elseif ($sort == \"type\") { $query .= ORDER BY user_type; } else { $query .= ORDER BY user_id\"); } [/php:1:d805344b15] I don\'t know the correct use of \" .= \" but I know it adds to a previous variable.
  4. thank you that makes a whole lotta sense >.> *is daft*
  5. Wow! Thank you Barand You are always a huge help!
  6. Arg, stuck again >.> How do I add all the values in a COLUMN. Example: Name --- Age Zach --- 17 Jake --- 16 Jim --- 12 So how would I go about adding all the values in the AGE column? Also, what column type should I use? I currently have INT, but is there anything better? the true use of this information will use used on a column with 8 digits (12345678). Thanx
  7. I was wondering how I can reorder the MySQL query \"order by\" with the use of forms. I have no clue. My friend owns this site, but because she knows ASP, rather than PHP, she was unable to help me. http://neoguide.dcwd.biz/Pet.asp See all the buttons? By clicking on them, the list order is changed.
  8. Awsome! Thank you Barand and DylanBlitz! You have both been incredably helpful! ^^
  9. Awsome! thank you, it worked. However, I have another question: If, say, for ID #3, votes=0, and points=0, the average will not even show up (you cant divide 0 by 0). For some reason, id #3 is placed ABOVE other IDs with actual averages. Ive tried both ASC, and DESC and the \"empty\" values do not move, only the IDs with actual averages, beneath them move. For example: Is there anyway to fix this? This doesn\'t work (because the empty values are NOT 0, they simply do not exist) Any other suggestions?
  10. Could someone give me an example? If I do it with variables, how can I order them BY the average?
  11. Im trying to return an average from a MySQL query. Here is my current query: What is the correct way (if any) to to mathematical equations in a query? Thank you for your help!
  12. Okay, I am trying to creating a ranking list based on total number of points. I have my page set up, and I\'m trying to figure out how to make it say \"1st Place\", etc. Here is my page so far: http://members.lycos.co.uk/triphis/ and im TRYING to get it like this: http://neoguide.dcwd.biz/Pet.asp I asked the owner of that site, but obviously she replied with an ASP command (Counter)... so how do you do it in PHP? Thank you
×
×
  • 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.