Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. Yes, you could do that. But why on earth would you? That's one of the most convoluted pieces of code i've seen in my life Edit: Actually i lied. You couldn't do that. That would only check to see if $row->AdminID was 20, since your variable $isitin is overwritten every time.
  2. My fault. The value of $track_num needs to be changed outside the if statement. Otherwise, it's value will never change - the if statement wont run until the value changes. if($row->ticketnumber != $track_num && $track_num != ''){ $this->display .= '<tr><td colspan="6"> </td></tr>'; } $track_num = $row->ticketnumber;
  3. So the row contains the literal text $CALL? If so, you need to demarcate the string with single quotes, not doubles. $CALL would be treated a variable and so would be evaluated inside those double quotes. Put it inside single quotes and it'll be treated as a literal. if($o_price == '$CALL') To further explain: $foo = 'bar'; echo $foo; //echos bar echo "$foo"; // echos bar echo '$foo'; //echos $foo Edit: Beaten to it but thought i'd post with those examples anyway.
  4. There's more than one way to skin a cat. You could set the values to things like "0 AND 100", "101 AND 300" and use them directly in your query (after using mysql_real_escape_string on them, of course). You could give them arbitrary values and use an if-else/switch statement or set the values to indexes in an array which contains the price ranges. Up to you really.
  5. Err, no. Typo: } esle { Should be: } else { Incidentally, what editor are you using to write your code? Anything with syntax highlighting would have made that easier to spot.
  6. 1.) You need to be ordering by the ticket number to ensure this works. 2.) You should define the variable prior to the loop starting. 3.) You should test the value of $track_num prior to changing it. Otherwise it'd always be true. <?php function sales_breakdown() { $query = $this->client->query("SELECT * FROM sales WHERE date = ".$this->yesterday." ORDER BY ticketnumber"); if ($query->num_rows() > 0) { $this->display .= " <table border='0' cellspacing='0' cellpadding='0' id='breakdown_table'> <tr bgcolor='".$this->bgcolor."'> <td width='280'>Item</td> <td width='60'>Price</td> <td width='70'>Type</td> <td width='60'>Till</td> <td width='60'>Time</td> <td width='110'>Ticket Number</td> </tr>"; $track_num = '';//define it before the loop - you shouldn't check against an undefined variable foreach ($query->result() as $row) { if($row->ticketnumber != $track_num && $track_num != ''){ //also check to make sure $track_num has been set. Dont want a blank row as the first row of the table. //print a blank row? This is where I get stuck $this->display . = '<tr><td colspan="6"> </td></tr>'; $track_num = $row->ticketnumber; } $this->display .= " <tr> <td>".$row->item."</td> <td>".$row->price."</td> <td>".$row->type."</td> <td>".$row->till."</td> <td>".$row->till."</td> <td>".$row->ticketnumber."</td> </tr>"; } } $this->display .= "</table>"; return $this->display; } ?> Revraz, you don't want to group by the ticket number. That'd mean you'd only have one row for each ticket number.
  7. Ok, so the above is a screenshot except that you added in some lines? If i understand you correctly, the correct approach is to order by the ticket number (which it looks like you've done). Then use a variable to keep track of the previous ticket number in your loop. Each time the loop runs, check to see if the ticket number in the row is different to the previous ticket number. If it is, output a blank row and update the ticket number variable. I can't give you any more than that without seeing the code. And if that's still not the problem you've got, you'll have to re-explain again.
  8. Perhaps it's just me, but i've no idea what the problem is. Do you have a database setup? Are you asking how you should store that information? Or how to retrieve it?
  9. I have a doubt too. I didn't think Outlook Express was a calendar program...
  10. At first glance, I can see a few problems. 1.) You pass a number in the URL to indicate which record to start at. So far, so good. But, you don't extract this variable from the $_GET array - you just use it. Assuming magic_quotes is turned off (which it should be), $s wont be defined. You need to do $s = $_GET['s'] before you can use it. 2.) It looks like you have intended to pass the user's search criteria through the URL, which is good. However, as far as i can see - you only pass $maker through the URL, not the model. Again, it's not extracted from the $_GET array and again, you test it before it's been defined at all. 3.) You want to be setting the number of pages using ceil(), not intval(). You need to always round up, otherwise you'll lose some records.
  11. This quote: Is shockingly inaccurate. The major changes were in PHP OO support. That said, the PHP team stopped supporting PHP 4 over a year ago. It really is time to upgrade.
  12. Yeah, you can't do that. You must test each value explicitly: if($var == 4 || $var == 20 || $var == 24){ //do something } Alternatively, you can place the possible values in an array and use the in_array() function: $values = array(4,20,24); if(in_array($var,$values)){ //do something } At present, your code tests to see whether or not the value of $row->AdminID is the string "3, 24, 20". As for an online directory, there's always the manual.
  13. I'm going to take a wild guess that this has absolutely nothing to do with mysql and you're just interested in displaying the first 50 characters with a "read-more" type link? Take a look at the substr function.
  14. You see that sticky, all written in capitals? Go read it.
  15. After 10 seconds googling, mssql doesn't support the limit clause. You'll need to use a derived table: SELECT Top 4 * FROM (Select * FROM ads WHERE Terminate > GETDATE() ORDER BY RAND() AS subtable) Never having worked with ms sql, i can't guarantee you'll need that alias at the end (or rather, that it'll work with it) - but you would do in mysql, so give it a whirl. Next time, you should post this question in the mssql board: http://www.phpfreaks.com/forums/index.php/board,35.0.html
  16. You've assigned the value of $_POST['uname'] to $user, but then used the undefined variable $uname to update with. This is why you should develop with error_reporting set to E_ALL and errors turned on - you would then have got an error message instead of scratching your head trying to figure out what went wrong.
  17. And you did turn on error_reporting, yes? It could be that the cURL extension wasn't installed, for example. Since you're logging into ebay, it could also be an SSL issue - are you ignoring ebay's certificate or providing certificates to verify against? Are you checking the return of curl_error()? Basically, we could do with seeing some code.
  18. See here. Same question was asked a few hours ago.
  19. I wish I only got 20 a day. My gmail account gets several hundred a day and sometimes upwards of 1k. Mine gets quite a lot too. However, i find gmail's spam filtering pretty damn good so it's not really a problem.
  20. Try using mysql_num_rows: <?php $sql = "SELECT column FROM table WHERE is_online = 1"; $results = mysql_query($sql); if(mysql_num_rows($results) > 0){ $newline = "<br />"; while($row = mysql_fetch_array($results)) { echo "" . $row['column'] . "" . $newline . ""; } }else{ echo 'Empty'; } ?>
  21. Though i've never used it, I believe the image magick extension does support animated gifs. Incedently, it's not the GD library that doesn't support animated gifs; it's PHP's implementation of it.
  22. It doesn't bother me in texts - i understand that, when limited to 160 characters, it's natural to try to abbreviate things and that, for some people, texting like that is quicker. That said, i generally text in proper english with predictive text turned on. Text talk on the internet does irritate me quite a lot though. You've got a proper keyboard, so use it!.
  23. That's pretty much correct. You then extract the variables on courseinfo.php from the $_GET array. Can you show us your actual code?
  24. You'll need another field, which can be an int. Assuming important should come higher than sticky (though i fail to see the need for a sticky and important topics) set important topics to 2, sticky topics to 1 and normal topics as the default of 0. In your ordering, order by this new field then by the last reply.
×
×
  • 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.