Jump to content

thunderousity

Members
  • Posts

    40
  • Joined

  • Last visited

Posts posted by thunderousity

  1. I've been beavering away with all things Wordpress and plugins etc The plugin I have installed and configured is great apart from an annoying issue with the sidebar and thumbnails not showing (Latest Classifieds) in IE8, but renders fine in other browsers. It doesn't look like there is an imminent release of a new version of the plugin so I'm trying to fix it myself. It's probably something simple but I can't see the wood for the trees. http://www.autosnout.com/For-Sale/car-classifieds/

  2. It sounds like you have another call to mysql_fetch_assoc at some point between when you run the query and when you run the loop. Using that function advances the result pointer, so the next time you use it it will return the next record.
    Yes you're correct - deleted the extra mysql_fetch_assoc and it works brilliantly - fantastic - thanks for the help :-)
  3. This works a treat - I've managed to tweak it slightly so it works for my descending mysql list by (amongst other things) changing the $min from 0 to 290 as I know that the highest value will be less than 280. I've also managed to incorporate my css alternating row color for the results. However, the results always miss the very first row from the resultset. The highest value was 273 but this was omitted, I added the value of 275 to the database table and the 273 now appears but not 275!?

    <?php$min = 290;$increment = 10;$max = $min - $increment;$rowclass = 0; while ($row_result = mysql_fetch_assoc($result)){  if ($row_result['number'] < $max)  {    while ($max > $row_result['number']) $max -= $increment;    $min = $max + $increment;echo "<br>";    echo "<h3 class='listrow'>Between ".$min." and ".$max."</h3>";}  echo "<div class= row" . $rowclass . "><div class='alignleft'><a title=" . $row_result['number'] . "text href=page.php?ID=" . $row_result['ID'] . ">" .$row_result['number'] . "</a></div><div class='alignright'>more text - <b>" . $row_result['number'] . "</b></div><div style='clear: both;'></div></div>";$rowclass = 1 - $rowclass;}?>

  4. I've not had chance to test this until I get home, but would something along these lines work using a 'while' statement rather than an 'if' $min = 0$max = 10$increment = 10$number = $row_result while (($number >= $min) && ($number <= $max)){echo "<h1>Between ".$min." and ".$max."</h1>";echo "<p>".$row_result['Result']."</p>";$min + $increment;$max + $increment;)

  5. The above sounds like a good solution - are there any scraps of code you could provide as an example. I understand how to increment using the ++ operator but I'm not sure what function to use to test for a max. From a novices point of view there seems to be a lot going on to try and put it all together without a little more direction any help appreciated

  6. One that will return all results. I attempted a version of the one below which is from the thread mentioned earlier - I thought it may work even though it is using strings. It worked for the hundreds as I added a zero to the header for the group and grouped it based on assessing the first 2 numbers (strlen). However, when it got to those with 2 rather than 3 numbers it added a zero to the 50 so the heading looked like 500 for example.

    <?php include 'connect.php'; $q = mysql_query("SELECT name FROM I3 ORDER BY name"); $first_letter = ''; while($row = mysql_fetch_assoc($q)) { // Check if the first letter is different than in previous rows if( $first_letter != strtoupper(substr($row['name'],0,1)) ) { // Only close a list if one is already open if( strlen($first_letter) ) echo '</ul>'; // Print a new title for the letter and open a new list echo "<h4>{$first_letter}</h4>"; echo '<ul>'; $first_letter = strtoupper(substr($row['name'],0,1)); } // Print the row value and whatever else you want echo "<li>{$row['name']}</li>"; } // Only close a list if one is already open. if( strlen($first_letter) ) echo '</ul>'; ?>
  7. You'll have to excuse my weak php knowledge. My understanding is that the while loop is ok for a list of rows for example. Ford MustangChevy CorvettePontiac Firebird However, I need to echo one of the 3 rows separately and uniquely in various parts of the page. Usually I echo a single result like so with the RAND LIMIT set to 1; Row 1 = Ford Mustang

    <h1>More <?php echo $row_rs['results'];?>Ford Mustang</h1>

    However, now I have 3 in the RAND LIMIT I have 3 rows. e.g. Row1 = Ford MustangRow2 = Chevy CorvetteRow3 = Pontiac Firebird Now I need to put a result for whichever row I decide into differing parts of the page. (The <?php echo $row_rs['Row n'];?> part is for example purposes only.)

    <h1>Car: <?php echo $row_rs['Row1'];?>Ford Mustang</h1>

    html...

    <p>Car: <?php echo $row_rs['Row3'];?>Pontiac Firebird</p>

    more html...

    <h3>Car: <?php echo $row_rs['Row2'];?>Chevy Corvette</h3>

    So somehow I think I need to put row 1, 2 and 3 into an array so that I can call them separately and uniquely. I hope that makes sense.

  8. I've currently got a mysql RAND() function to select random rows of data. (Not the most efficient method but it works) My current code returns 1 record but I want to return 3 results so I've changed the LIMIT from 1 to 3 as below. $query_rs = "SELECT * FROM tblexample ORDER BY RAND() LIMIT 3";$rs = mysql_query($query_rs, $database) or die(mysql_error());$row_rs= mysql_fetch_assoc($rs);$totalRows_rs = mysql_num_rows($rs); I need to include the individual rows in various parts of my web page. e.g. Result 1 at the top of the page, Result 2 and 3 elsewhere.How can I alter the code so that I can reference and include the 3 results individually. I assume I can put these in some sort of array.

  9. apologies - just tried the w3c html validator and you're correct there are 67 errors. However, these errors relate to the poor code in the embedded ebay ads which I can do little about. Correct me if I am wrong but these errors have nothing to do with the firefox issue I have.

×
×
  • Create New...