Jump to content

Zane

Administrators
  • Posts

    4,362
  • Joined

  • Last visited

  • Days Won

    11

Everything posted by Zane

  1. Well it looks as though you're going to get them in ascending order no matter what. I'm no SQL genius so I can't really come up with some cool cure-all query. In your situation, I would get all the results like they are, put them into a multidimensional array and use the variables accordingly. And use the product id as the index in this array. For instance. while($row = mysql_fetch_array($result)) { $rows[$row['Product_ID']] = $row; } // Now you have an array like this echo "" , print_r($rows) , ""; /// To access one of these product arrays.. simply use the Product_ID. echo $rows['465']; // ... etc Now, to print out all of the fields for each product, you will use a foreach() loop. The main problem now though is that you need to loop through the array of arrays. This is where you can take advantage of PHP and order your array the way you see fit. Simply put.. $desiredProducts = array(475,465,930); foreach($desiredProducts as $product) { foreach($rows[$product] as $field => $data) echo $field . " " . $data . " \n"; }
  2. It probably has to do with your while statement while($row = mysql_fetch_array($result)) { echo "$x"; echo " "; if ($x==1) $one = $row['Product_ID']; if ($x==2) $two = $row['Product_ID']; if ($x==3) $three = $row['Product_ID']; if ($x==4) $four = $row['Product_ID']; if ($x==5) $five = $row['Product_ID']; $x++; } echo $one; In this, you are attempting to create new variables ... relative to the $x counter value. Yet, you're only echoing $one... unless you have the others elsewhere. This in itself is just a bad idea anyway. What do you suppose to do with fifty products? Create fifty variables? Why? Try this while() loop and see if you don't change your mind. while($row = mysql_fetch_array($result)) { echo $row['Product_ID'] . " \n"; }
  3. You didn't read the post, did you? Use ORDER BY FIELD(). Use field() the same way you'd use IN() SELECT * FROM table WHERE id IN (6,9,3,7,2) ORDER BY FIELD (6,9,3,7,2)
  4. I don't see the logic behind having a double while loop. That inner while loop is why it repeats the products. As for getting them in that particular order, that would be better asked in the MySQL board.. which I could move this to if you'd like.
  5. These are all neat ideas and all, but unless someone codes this modification, it's not gonna happen. Not to mention, we the staff must approve it. I also doubt SMF is gonna adapt anything more than their current karma system anytime soon. If you feel you can create the mod, then make it and submit it to SMF. Though I must warn you, just from past experience doing so, that SMF is STRICT.
  6. You would need for the clients to access your images through a PHP script... that acts as the image src For instance, you clients won't have an image path, but a path to a PHP script with query variable in it. Let's say you have a PHP file on your server called.... advert.php if(isset($_GET['src']) { $imagepath=$_GET['src']; /* Here you could have either an index number or a filename.. whatever you have in your database. The point is that you use what is in the $_GET['src'] variable to return an image object. */ $image=imagecreatefromjpeg($imagepath); // get image height $imgheight=imagesy($image); //allocate color for image caption (white) $color=imagecolorallocate($image, 255, 255, 255); //Add text to image bottom imagestring($image, 5, 100, $imgheight-50, "September 2005", $color); header('Content-Type: image/jpeg'); imagejpeg($image); } ?> Then, you can give your client an img source of something like http://mysite.com/advert.php?src=bigoleadvertisement Or if you're using the index way, http://mysite.com/advert.php?src=555
  7. Zane

    Firefox 6

    I don't believe I'm going to upgrade to 6. Mozilla's aim here is to catch up with the current browser version numbers, so as to blend in better somehow. It won't be long and Firefox 7 will be out, then 8,9 & 10. They might even go as far as 11. I think I'll just upgrade to the even numbered ones.
  8. http://www.phpfreaks.com/forums/index.php?topic=208965.0 example SQL: from http://www.phpro.org/tutorials/Geo-Targetting-With-PHP-And-MySQL.html SELECT :unit * ACOS( SIN(RADIANS(:lat_from)) * SIN(RADIANS(:lat_to)) + COS(RADIANS(:lat_from)) * COS(RADIANS(:lat_to)) * COS(RADIANS(:long_from) - RADIANS(:long_to))) AS distance
  9. This is the way I would do it. $partnumber = "PLEl25o5"; $sql = "SELECT * FROM parts\n"; $sql .= "WHERE partnum = '$partnumber'\n"; if(strpos($partnumber, "l") != false) $sql .= "AND (partnum LIKE '%l%' OR partnum LIKE '%1%')\n" if(strpos($partnumber, "s") != false) $sql .= "AND (partnum LIKE '%s%' OR partnum LIKE '%5%')\n" if(strpos($partnumber, "o") != false) $sql .= "AND (partnum LIKE '%o%' OR partnum LIKE '%0%')\n" echo $sql; // run query with $sql ?> It's not tested, but all I'm doing is concatenating the SQL query conditionally whenever those letters appear.
  10. It's really only thrilling when you play it online. Someone hosts a Minecraft Server and all your buddies connect to it. Then you load up Skype or ventrilo and start buildin'. I couldn't understand the hype either.. until I got on a server with my friends. It's rather addicting. We should totally host a PHPF minecraft server.
  11. Any one out there play Minecraft? Me and my friends have been trying to set up a server, but our ISP makes it a pain in the ass to almost impossible. Just looking to joining a good server really.
  12. I think what he's talking about is the actual slideshow effect. Where either the pictures move fluidly in a right-to-left motion or it moves upon a mouse event. These types of UI can only be done with, yes, the cursed javascript. Unless of course you make it in Flash or Java.
  13. This seems like the quickest way to me. $marray = array(); for ($i=0;$i $marray[$i] = array(); for ($j=3;$j>0;$j--) $marray[$i][] = $j; }
  14. $5daysma=(mysql_result($result,$i,"AVG(close)"); You can't have variables that start with a number. Also, in your query, you should give avg(close) an alias so it's easier to get out of the array. $query="SELECT avg(close) as 5dayavg, ticker FROM nse_equity_eod_data GROUP BY ticker LIMIT 5 ORDER BY date DESC"; Then you can do this. $fivedays_ma =(mysql_result($result,$i,"5dayavg");
  15. Doesn't your router not have DNS capabilities incorporated? Usually you can set those types of things for a LAN on the router itself.
  16. Why do you have them type ... or copy and paste ... and MD5 string? why not just append it to the link you email them ... as a $_GET variable?
  17. What is the purpose of $x? From your code I can only assume it is to capture the first loop because you aren't incrementing $x.
  18. xmlhttp.responseText will contain whatever search_mysql.php?q="+str contains.. In other words, responseText is just that, text. In order to parse out a specific variable, you'll need to manipulate what search_mysql.php outputs so you can parse through it. For instance. You could have it ouput txtHint:topurl then use the split function to split on :
  19. Why not just display the lightbox on the registration page and use document.location to redirect on close of the lightbox..?
  20. Firstly, give your form a name attribute </pre> <form method="POST" action="null" name="'myform'"> < Secondly, add this line below the line for txtHint document.myform.action = 'whatever';
  21. PS, AI and Fireworks are all part of the same package. In other words, they all *can* work together.
  22. can you show the whole code. I can't decipher what you're doing from the code you provided.
  23. Read up on output buffering .. and flushing http://php.net/manual/en/function.flush.php
  24. You can't output anything after a redirect, it's completely illogical. It's like sending someone to the store and then after they're gone, pulling out the needed money.
×
×
  • 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.