Jump to content

ChambeRFienD

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Everything posted by ChambeRFienD

  1. Alrighty.. Figured it out myself.. $sql = "SELECT prices.price AS price, products.pname AS pname, products.prodno AS prodno FROM prices, products WHERE prices.prodid = products.prodno ORDER BY prices.price ASC LIMIT 20"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { echo $row['price'] . " - " . $row['pname'] . " - " . $row['prodno'] . "<br />\n"; }
  2. Well.. I have a MySQL database with 2 tables in it. products and prices.. Products has a field in it called 'prodno'. Prices has a field in it called 'prodid'. There is one of each item in products and each product has it's own unique 'prodno' There are multiple instances of each product's pricing in prices.. One for each price.. So if a product had multiple prices depending on quantity it would have an entry for each price.. Example: id = 1 prodid = 7001 qty = 300 price = 12.5 id = 2 prodid = 7001 qty = 400 price = 15.5 I was wondering if I could query the database getting info from the products table but sort it according to the prices in the prices table. Kinda like doing a "SELECT * FROM products" ordering it by the lowest price value from each item.. This is all very confusing to me, and I'm the one writing it. Let's try one last time.. Query the database selecting * from products (I plan on using all the info in products) and ordering them by the lowest price for each item in the prices table. I've tried sorting the results of just a basic SELECT * FROM products using Javascript and PHP but with pagination in the results it makes it a bit hard.
  3. [quote author=AndyB link=topic=106144.msg424269#msg424269 date=1156886321] [code]<?php if ($thing><100) {   echo "an error"; } else {   $newthing = 25*ceil($thing/25); // result   .... any other code ... } ?>[/code] [/quote] Thanks much!
  4. Hello, I'd like to write a script to only accept numbers that are multiples of 25, starting at 100 and ending at 50,000... So if they select something lower than 100 they get an error, something higher than 50,000 they get an error, and if they enter something like 101, it will round it to 125.. I'm sure I could do this with a select(), but it would be an extreme pain to do that for every 25 all the way up to 50,000... To clear things up: If they enter 101 in the field, it will round it to 125. If they ender 24,142 it will round to 24,150.. Anyone know a way to do this?
  5. Hello, I'm trying to make a small quote estimate script. I need to make it so that if someone selects one option in a drop down list, depending on what is in the drop down list it will make a new field (such as an input box) appear below it. Anyone know how to do this? I've seen it on some other websites but I never really looked into it. I'm sure it also has something to do with some Javascript too.
  6. [quote author=tomfmason link=topic=105499.msg421534#msg421534 date=1156445714] I think that you want [url=http://us3.php.net/manual/en/function.odbc-num-rows.php]odbc_num_rows[/url]. Hope this helps, Tom [/quote] Doesn't work with Access drivers. Returns with -1
  7. [quote author=johndcastro link=topic=105499.msg421477#msg421477 date=1156439009] Are you tring to loop through using while? If you you can use while (odbc_fetch_row($cur) { [/quote] I just need to count the number of entries in a database that match a query.. Example: [code]$query = odbc_exec($odbc, "SELECT * FROM user_info WHERE cc='$search'") or die("MySQL Database Error: " . odbc_errormsg()); $count = counting_funtion($query); if($count >= ......[/code]
  8. I'm currently converting a script from using MySQL to Access. The only part I'm having trouble with is getting a mysql_num_row alternative for Access... Anyone have any ideas?
  9. Well, I'm writing a script to check a list of domains in a CSV file to see if they are being parked at GoDaddy or not. The script works, it just takes FOREVER to check just 2 domain names... [code]<h1>CSV Domain Check</h1> <?php $row = 1; $handle = fopen("file.csv", "r"); while (($data = fgetcsv($handle, 500, ",")) !== FALSE) { $num = count($data); for ($c=0; $c < $num; $c++) { fopen($data[$c], "r"); $handle2 = fopen($data[$c], "r"); $contents = stream_get_contents($handle2, 1024); $matchPattern = '.*Coming Soon!.*'; if (ereg($matchPattern, $contents, $result)) { echo $data[$c] . "<br />\n"; } else { } } } fclose($handle); ?> [/code] Anyone have any idea on how to make this go faster?
  10. First off, what version of PHP is the book teaching you? Also, what exactly isn't matching up?
  11. [!--quoteo(post=383437:date=Jun 13 2006, 03:49 PM:name=joquius)--][div class=\'quotetop\']QUOTE(joquius @ Jun 13 2006, 03:49 PM) [snapback]383437[/snapback][/div][div class=\'quotemain\'][!--quotec--] @php.net: [/quote] Thanks much for that.. A lot easier than what I was thinking. I was heading more towards the system() function. =x Using this now: [code]<? $host = 'lkasdflkawefhasdh.com'; $ip = gethostbyname($host); if($ip == $host) {     echo "Unable to find host."; } else {     echo $ip; } ?>[/code] Now to grab the titles from websites..
  12. I've heard of people being able to pull text from a website using fopen or something of the sort, but I'm looking to write a little PHP program to make my job go a bit faster at work. (We deal with a lot of domain names) I was wondering if there was a way to ping a website with PHP and return the IP address of that site. I'm also looking for a way to pull the title from a website and return that if possible. Anyone have any ideas that could help me out?
  13. [!--quoteo(post=368999:date=Apr 26 2006, 05:14 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 26 2006, 05:14 PM) [snapback]368999[/snapback][/div][div class=\'quotemain\'][!--quotec--] When you insert data into the database use [code]<?php mysql_real_escape_string(stripslashes($data)) ?>[/code] Ken [/quote] Thanks much! I'll give that a shot.
  14. [!--quoteo(post=368994:date=Apr 26 2006, 04:55 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 26 2006, 04:55 PM) [snapback]368994[/snapback][/div][div class=\'quotemain\'][!--quotec--] What do you me by Ken [/quote] Well, if I try using the search function above with an apostrophe in it, slashes show up there. Slashes are showing up in results from my MySQL queries.. All I want is a good way to make it so I can have data inserted into a database that may include apostrophies, quotations, and more, and not have slashes show up when pulling them from the database..
  15. Anyone else able to help me with this? I have slashes all over my website right now. =P
  16. [!--quoteo(post=368716:date=Apr 25 2006, 11:14 PM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Apr 25 2006, 11:14 PM) [snapback]368716[/snapback][/div][div class=\'quotemain\'][!--quotec--] $alt_id = $row_alts['trade_id'\]; $alt_name = stripslashes($row_alts['trade_name']); $alt_status = $row_alts['trade_level'\]; $alt_owner = $row_alts['trade_owner'\]; what about back slash [/quote] Hmm? Still kinda new to PHP. =P
  17. [!--quoteo(post=368709:date=Apr 25 2006, 10:47 PM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Apr 25 2006, 10:47 PM) [snapback]368709[/snapback][/div][div class=\'quotemain\'][!--quotec--] Show your form for inserting data [/quote] [code]    <form action='?page=search' method='post'>     Search:<br />     <input type='text' name='search' class='input_box' /> <br />     <input name='function' value='owned' checked='checked' type='radio' /> Owned Alts<br />     <input name='function' value='wanted' type='radio' /> Wanted Alts<br />     <input name='function' value='users' type='radio' /> Users<br />     <br />     <input type='submit' value='Search' />     </form>[/code]
  18. Okay... Using this: [code]            $search = $_POST['search'];             echo $search; //Comes out as test\'d when entering test'd             echo "<h3>Searching owned alts for '$search'</h3>";             echo "<table cellspacing='0' class='alttable' width='100%'>";             $get_alts = mysql_query("SELECT * FROM alts_trade WHERE trade_name LIKE '%$search%' ORDER BY trade_name ASC");             $count = mysql_num_rows($get_alts);             echo "<font size='-2'>There are $count result(s) that match your search!</font>";             while($row_alts = mysql_fetch_array($get_alts)) {                 $alt_id = $row_alts['trade_id'];                 $alt_name = stripslashes($row_alts['trade_name']);                 $alt_status = $row_alts['trade_level'];                 $alt_owner = $row_alts['trade_owner'];                 if($altcolor == 0) {                     $class = 'altcolor1';                 } else if($altcolor == 1) {                     $class = 'altcolor2';                 }                 switch($alt_status) {                     case 4:                         $alt_level = "Not for Trade";                     break;                     case 5:                         $alt_level = "On Hold";                     break;                     case 6:                         $alt_level = "Open for Trade";                     break;                 }                 $get_owner = mysql_query("SELECT * FROM phpbb_users WHERE user_id=$alt_owner");                 $row_owner = mysql_fetch_array($get_owner);                 $owner_name = $row_owner['username'];                 echo "<tr><td class='$class'><a href='?page=alt&amp;alt=$alt_id'>$alt_name</a> - $alt_level - Owned by: <a href='profile.php?mode=viewprofile&amp;u=$alt_owner'>$owner_name</a>&nbsp - &nbsp;";                 if($user_level > 0) {                     echo "<a href='?page=edit_alts&amp;mode=admin&amp;alt=$alt_id'>Edit Me</a> | <a href='?page=edit_alts&amp;mode=admin&amp;f=delete&amp;alt=$alt_id'>Delete Me</a>";                 }                 echo "</td></tr>";                                  if($altcolor == 0) {                     $altcolor++;                 } else if($altcolor == 1) {                     $altcolor--;                 }             }             echo "</table>"; [/code] In my database, I have this: test\'d BUT, it comes up with no results.. Echoing $search comes out with test\'d.. Even before I addslashes.
  19. Well, I'm having one HECK of a time trying to get my code to work... I'm trying to make it so people can add names to a database, some which will include apostrophes and quotation marks.. I've tried using addslashes, mysql_real_escape_string, and right now my code is a mess with a mixture of both, which is coming out with bad end results.. Currently I am using mysql_real_escape_string for everything going into an SQL query. The problem is, retrieving data from the database comes out with several slashes.. I've been trying to use stripslashes to remove them with no luck. My question is, what is the best thing to do when trying to insert and remove text into a MySQL database without getting SQL errors? If anyone would like to see the code, feel free and ask. it's about 3041 lines, but searching for mysql_real_escape_string and stripslashes will show you all of my attempts. =P
  20. [!--quoteo(post=366279:date=Apr 18 2006, 10:03 PM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Apr 18 2006, 10:03 PM) [snapback]366279[/snapback][/div][div class=\'quotemain\'][!--quotec--] [code] if(! $user_level == 1) {                         echo "$user_level<br />There's no way you're supposed to be here.. Tisk tisk."; [/code] [code] if($user_level ! >0) {                         echo "$user_level<br />There's no way you're supposed to be here.. Tisk tisk."; [/code] Tried good luck! [/quote] I can't remember what I did, but I managed to fix it a couple minutes ago. Thanks for the reply though. =)
  21. Try this: $query = "UPDATE users SET username=\"$username\", user_password=\"$password\", email=\"$email\", user_level=\"$userlevel\" WHERE id=\"$id\"";
  22. [code] case 'admin':                 echo $user_level;                 if($user_level == 1) {                     echo "<h3>Administrative Alt Edit</h3>";                     if(isset($_GET['f'])) {                     $alt_id = $_GET['alt'];                     $sql_check = mysql_query("SELECT * FROM alts_trade WHERE trade_id='$alt_id'");                     $row_check = mysql_fetch_array($sql_check);                     $alt_name = $row_check['trade_name'];                     if($user_level == 1) {                         mysql_query("DELETE FROM alts_trade WHERE trade_id='$alt_id'");                         echo "<strong>$alt_name was deleted from the database!</strong>";                     } else {                         echo "<strong>You cannot delete alts from other people's lists!</strong>";                     }                     $trade_id = $_GET['alt'];                     $sql_info = mysql_query("SELECT * FROM alts_trade WHERE trade_id='$trade_id'");                     $row_info = mysql_fetch_array($sql_info);                     $comments1 = $row_info['trade_comments'];                     $name1 = $row_info['trade_name'];                     $level1 = $row_info['trade_level'];                     if($user_level != 1) {                         echo "$user_level<br />There's no way you're supposed to be here.. Tisk tisk.";                     } else {                         if(isset($_POST['edited'])) {                             $alt_id = $_POST['edited'];                             $comments = mysql_real_escape_string($_POST['comments']);                             $name = mysql_real_escape_string($_POST['name']);                             $level = $_POST['level'];                             mysql_query("UPDATE alts_trade SET trade_name='$name', trade_comments='$comments', trade_level='$level' WHERE trade_id='$alt_id'") or die(mysql_error());                             echo "<b>Alt Edited</b><br />                             <font size='-2'><i>Changes will not be seen til you return to your alt list!</i></font>";                         }                     }                     echo "<form action='?page=edit_alts&amp;mode=admin&amp;&amp;e=1&amp;alt=$trade_id' method='post'>";                     echo "<table border='0' cellpadding='0' cellspacing='10'>";                     echo "<input type='hidden' name='edited' value='$trade_id' />";                     echo "<tr><td><font size='-2'>Owned Alt</font><br /><input type='text' name='name' value='$name1' size='15' /></td></tr>";                     echo "<tr><td><font size='-2'>Trade Level</font><br /><select name='level'>";                     echo "<option value='6'"; if($level1 == 6){ echo "selected";} echo ">Open for Trade</option>";                     echo "<option value='5'"; if($level1 == 5){ echo "selected";} echo ">On Hold</option>";                     echo "<option value='4'"; if($level1 == 4){ echo "selected";} echo ">Not For Trade</option>";                     echo "</select></td></tr>";                     echo "<tr><td><font size='-2'>Comments:</font><br /><textarea name='comments'>$comments1</textarea></td></tr>";                     echo "<tr><td><br /><input type='submit' value='Edit Alt'></td></tr></table>";                     echo "</form>";                 } else {                     echo "<br />There's no way you're supposed to be here.. Tisk tisk.";                 }                 }             break; [/code] When this is run, it echos '1' for the $user_level variable, but it still shows "<br />There's no way you're supposed to be here.. Tisk tisk." Anyone have any ideas why?
  23. Sorry I haven't updated this topic yet, but I figured it out. I didn't have the nav and content displayed as inline, and IE messed the margins up because of it. =P
  24. [a href=\"http://joshmoyers.com/dev/FAMv3\" target=\"_blank\"]http://joshmoyers.com/dev/FAMv3[/a] [a href=\"http://joshmoyers.com/dev/FAMv3/famstyle.css\" target=\"_blank\"]http://joshmoyers.com/dev/FAMv3/famstyle.css[/a] Can anyone figure out how I can get the content and nav sections to work in IE like they do with Firefox? =P
  25. How would I go about finding the difference between a date stored in the 'DATE' type in a MySQL database and the current date.. Just looking for how many days there are between the current date and what is stored in the database.
×
×
  • 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.