Jump to content

Borderline

Members
  • Posts

    58
  • Joined

  • Last visited

Borderline's Achievements

Newbie

Newbie (1/7)

1

Reputation

  1. Hi, I'm looking for some advice. I have a raceform website; the template was purchased and has a web search field already set up which I'd like to utilize. I've been looking online at questions/answers relating to people coding their own search tools, and in many people have suggested using scripts like Sphider instead. My site is built in PHP/MYSQLI, and I consider myself a novice. There will be a minimum of 600 pages to index, and all I'm wanting is for the content between the title tags to be indexed - for example, the horse's name appears within the title tags of his individual page, and that's literally the only page I wanted displayed if someone were to search his name (results pages etc should be ignored). My question is, how would you recommend progressing from here? Am I genuinely better using a pre-created script, or would a basic search tool that I've created be sufficient. Can you recommend any tutorials or scripts? A lot of the scripts and tutorials seem to have been produced several years ago, so I was wondering if there was anything created more recently? Any advice is much appreciated!
  2. Afternoon I set up a substring on the raceid column of my database; the raceid column consists of the season+individual race number, to produce a unique id number. Image of the database below - my code was doing what I expected (hoped for?!) and outputting the four digit season. However, I've since done an inner join on the two tables, and the season is now missing from the output i.e. there's just a gap where I would expect the season to appear. <?php $result1 = mysqli_query($con,"SELECT runners.raceid, SUBSTRING(runners.raceid,1,4), runners.horse, runners.age, runners.colour, runners.gender, runners.trainer, runners.t_link, runners.owner, runners.o_link, horse.horse, horse.sire, horse.s_ctry, horse.dam, horse.d_ctry FROM runners INNER JOIN horse ON runners.horse = horse.horse WHERE runners.h_link = '01335.php' ORDER BY runners.raceid DESC LIMIT 1");?> The output (this is an include): <?php while($row = mysqli_fetch_array($result1)) { include($_SERVER['DOCUMENT_ROOT'].'/inc/links.php'); echo "Last raced at the age of "; echo $row['age']; echo " during the "; echo $row['SUBSTRING(raceid,1,4)']; echo " season."; echo "</br>"; echo "</br>"; echo " <b>Colour/Gender:</b>"; echo "</br>"; echo $row['colour'] . " " . $row['gender']; echo "</br></br>"; echo " <b>Trainer:</b>"; echo "</br>"; echo "<a href=".$trainerlink . ">" .$row['trainer'] . "</a>"; echo "</br></br>"; echo " <b>Owner:</b>"; echo "</br>"; echo "<a href=".$ownerlink . ">" .$row['owner'] . "</a>"; echo "</br></br>"; echo " <b>Sire:</b>"; echo "</br>"; echo "<a href=".$sirelink . ">" .$row['sire'] . "</a>"; echo "</br></br>"; echo " <b>Dam:</b>"; echo "</br>"; echo "<a href=".$damlink . ">" .$row['dam'] . "</a>"; } ?> Any advice would be very much appreciated.
  3. Many thanks for the speedy response. I've never looked into temporary tables - will go have a read up to see what the score is. Thanks!
  4. Afternoon I'm working on producing a series of pages that pull data from several databases. I've generated an index on the data (raceid), as when I first joined the tables, the resulting page was horribly slow to load. Testing in this instance was on a limited number of rows (approx 750) on a different server, and the result was excellent. I've since finished the data collation, which has resulted in 11,969 rows in the main database. I've tried a similar code on this dataset but despite the index, the page fails to load and provides an error message: Internal Server Error - The server encountered an internal error or misconfiguration and was unable to complete your request. The result loaded fine with the horse and jockey joins, it was only when the third join was added that the issue occurred. I was wondering whether anyone could advise me on how to proceed - am I asking for an unrealistic result, or is there an issue with my code? Is there a chance the change of webhost could be a problem - my current hosting is shared, whereas my previous was a VPS. I attached below the current SQL, and would be grateful for any advice/pointers. $result = mysqli_query($con,"SELECT runners.raceid, runners.pos, runners.horse, runners.eqp, runners.age, runners.weight, runners.rat, runners.dist, runners.beat, runners.jockey, runners.trainer, horse.horse, horse.h_ctry, horse.h_link, jockey_career.jockey, jockey_career.careerlink, trainer_career.trainer, trainer_career.careerlink FROM runners INNER JOIN horse ON runners.horse = horse.horse INNER JOIN jockey_career ON runners.jockey = jockey_career.jockey INNER JOIN trainer_career ON runners.trainer = trainer_career.trainer WHERE runners.raceid = 2000001 ORDER BY runners.runid"); Thanks Charlie
  5. Thanks, appreciate the speedy response. Apologies for the omission, the tutorial is located at: http://blog.teamtreehouse.com/how-to-code-sortable-tabular-data-with-jquery The web console isn't showing any errors, so I'll go back to basics and try it again, I'm sure there's something I've forgotten.
  6. I'm new to jquery and am looking for some advice. I attempted to set up the jquery tablesorter on my site, with no success. I then removed it, and set up a sample table code for test purposes using this tutorial: I've since tried substituting my own table into the code instead, which has stopped the sorting from working correctly. The main difference that I can see is that the contents of my table is being pulled from a database. Additionally, my template uses jquery-1.7.1.min.js, but tablesorter uses jquery-1.10.2.min.js. Thus far, I've linked both files in my head section, as the navigation wouldn't display correctly with jquery-1.10.2.min.js only. I'm not sure if either of these points would affect the end result? Sample page: http://www.arabianraceform.co.uk/form/horses/00002test.php Query <?php $result = mysqli_query($con, "SELECT runners.raceid, runners.weight, runners.rat, runners.eqp, runners.pos, runners.beat, runners.plus, runners.price, runners.jockey, race.raceid, race.dateshort, race.cshort, race.racetype, race.distf, race.run, race.ground, race.raceurlFROM runnersInner Join race Onrunners.raceid = race.raceidWHERE runners.horse = 'Wikkara'ORDER BY runners.raceid DESC"); ?> <?php include($_SERVER['DOCUMENT_ROOT'].'/inc/tables/horses.php');?> <?php mysqli_close($con);?> Table insert code: <?php echo "<table id='keywords'> <thead> <tr> <th>Date</th> <th>Course</th> <th>Race Type</th> <th>Dist</th> <th>Going</th> <th>Weight</th> <th>Rating</th> <th>Eqpt</th> <th>Pos</th> <th>Beaten</th> <th>Jockey</th> <th>Price</th> </tr> </thead>"; while($row = mysqli_fetch_array($result)) { include($_SERVER['DOCUMENT_ROOT'].'/inc/links.php'); echo "<tbody>"; echo "<tr>"; echo "<td>"; echo "<a href=".$racelink . ">" .$row['dateshort'] . "</a><br>"; echo "<td>" . $row['cshort'] . "</td>"; echo "<td>" . $row['racetype'] . "</td>"; echo "<td>" . $row['distf'] . "</td>"; echo "<td>" . $row['ground'] . "</td>"; echo "<td>" . $row['weight'] . "</td>"; echo "<td>" . $row['rat'] . "</td>"; echo "<td>" . $row['eqp'] . "</td>"; echo "<td>" . $row['pos'] . "/" . $row['run'] . "</td>"; echo "<td>" . $row['beat'] . "" . $row['plus'] . "</td>"; echo "<td>" . $row['jockey'] . "</td>"; echo "<td>" . $row['price'] . "</td>"; echo "</tr>"; } echo "</tbody>"; echo "</table>";?> <script type="text/javascript"> $(document).ready(function() { $('#keywords').tablesorter(); }); </script> CSS Code table { border-collapse:collapse; width:100%; } #keywords { margin: 0 auto; font-size: 1.2em; } #keywords thead { cursor: pointer; background: #c9dff0; } #keywords thead tr th { font-weight: bold; padding: 2px 2px 2px 2px; } #keywords thead tr th span { padding-right: 20px; background-repeat: no-repeat; background-position: 100% 100%; } #keywords thead tr th.headerSortUp, #keywords thead tr th.headerSortDown { background: #acc8dd; } #keywords thead tr th.headerSortUp span { background-image: url('/images/tables/up-arrow.png'); } #keywords thead tr th.headerSortDown span { background-image: url('/images/tables/down-arrow.png'); } #keywords tbody tr { color: #555; } #keywords tbody tr td { text-align: center; padding: 2px 2px 2px 2px; } #keywords tbody tr td.lalign { text-align: left; } #keywords td, #keywords th, #keywords table { border: 1px solid black; } Any help would be greatly appreciated.
  7. Thanks for the reply. Doing that gets me a strange result: http://www.further-flight.co.uk/site/test/justsomeguy.php function uc_names($s){ return preg_replace_callback("/(\b[\w|']+\B)/s", 'fixcase_callback', $s); //return $s;}function fixcase_callback($word){ $word = $word ; $word = strtolower($word); if($word == "de") return $word; $word = ucfirst($word); if(substr($word,1,1) == "'") { if(substr($word,0,1) == "D") { $word = strtolower($word); } $next = substr($word,2,1); $next = strtoupper($next); $word = substr_replace($word, $next, 2, 1); } return $word;} // Get all the data from the table $result = mysql_query("SELECT horse, jockey FROM testnames") or die(mysql_error()); echo "<table class='correctenglish' border='1' cellpadding='4' cellspacing='0' width='50%'>"; echo "<tr class='toprow'><th>Horse</th> <th>Jockey</th></tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr>"; echo "<td align='center'>"; echo uc_names($row['horse']); echo "</td>"; echo "<td align='center'>"; echo uc_names($row['jockey']); echo "</td>"; echo "</tr>"; } echo "</table>";
  8. Many thanks for the speedy reply (as always). I'm not getting the right output, and was wondering whether you could advise how to dealt with the echoing part of the code? I've not previously dealt with a pair of functions.
  9. I'm trying to produce a result whereby horse & jockeys names are capitalized correctly. My current results are located here: http://www.further-f...t/testupper.php McNaughton & Billie-Jo are showing correctly, but McDonald and O'Connor aren't. Additionally, I'd like to attempt to have Ii displayed as II. My code is below - could it be tweaked to correct these issues, or is there a better way of achieving all this anyway? Any info gratefully received. <?PHP function FormatName($name=NULL) { if (empty($name)) return false; $name = strtolower($name); $names_array = explode('-',$name); for ($i = 0; $i < count($names_array); $i++) { if (strncmp($names_array[$i],'mc',2) == 0 || ereg('^[oO]\'[a-zA-Z]',$names_array[$i])) { $names_array[$i][2] = strtoupper($names_array[$i][2]); } $names_array[$i] = ucfirst($names_array[$i]); } $name = implode('-',$names_array); return ucwords($name); } // Get all the data from the table $result = mysql_query("SELECT horse, jockey FROM testnames") or die(mysql_error()); echo "<table class='correctenglish' border='1' cellpadding='4' cellspacing='0' width='50%'>"; echo "<tr class='toprow'><th>Horse</th> <th>Jockey</th></tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr>"; echo "<td align='center'>"; echo FormatName($row['horse']); echo "</td>"; echo "<td align='center'>"; echo FormatName($row['jockey']); echo "</td>"; echo "</tr>"; } echo "</table>";?>
  10. Borderline

    Sum problem

    Please find below: Comptipsterselections Comptipsterboard:
  11. Borderline

    Sum problem

    I've looked again at my code, and made an adjust, so that it now reads: <?php $query = " SELECT SUM(comptipsterselections.profit) as Profit, comptipsterselections.stable, comptipsterboard.link FROM comptipsterselections INNER JOIN comptipsterboard ON comptipsterselections.stable=comptipsterboard.stable WHERE comptipsterselections.comp = 'aintree 2010' GROUP BY comptipsterselections.stable, comptipsterboard.link ORDER BY SUM(comptipsterselections.profit) DESC"; $result = mysql_query($query) or die(mysql_error()); // Set-up table echo "<table class='correctenglish' border='1' cellpadding='4' cellspacing='0' width='75%'>"; echo "<tr class='toprow'> <th>Stable</th> <th>Daily Profit</th></tr>"; // Print out result while($row = mysql_fetch_array($result)){ $link='/site/competitions/tipster'.$row[link]; echo "<tr><td>"; echo "<a href='$link'>"; echo $row[stable]; echo "</td><td>"; echo " £". $row[Profit]; echo "</td></tr>"; } echo "</table>"; ?> The profit for each player is now showing correctly for each player. However, the printed results now show links for each competition the player has taken part in, not just the Aintree 2010 competition: http://www.further-flight.co.uk/site/competitions/tipster/aintr/sp/2010c.php I thought the WHERE clause would filter out anything that didn't have Aintree 2010 in the comp column, but this isn't the case. Is there any advice for getting this added to the code? Many thanks.
  12. Borderline

    Sum problem

    I'm sorry - yes it is.
  13. Borderline

    Sum problem

    Good evening I'm afraid I'm looking for yet more advice. I run a tipping competition, with data as follows: I'm trying to get the data to calculate the profit for each player over the course of the competition, which can last for up to five days. I have some code, which is producing a profit/loss, but not the correct one! I was hoping someone could advise where I'm going wrong. <?php $query = " SELECT SUM(comptipsterselections.profit) as Profit, comptipsterselections.stable, comptipsterboard.link FROM comptipsterselections INNER JOIN comptipsterboard ON comptipsterselections.stable=comptipsterboard.stable WHERE comptipsterboard.comp = 'aintree 2010' GROUP BY comptipsterselections.stable, comptipsterboard.link ORDER BY SUM(comptipsterselections.profit) DESC"; $result = mysql_query($query) or die(mysql_error()); // Set-up table echo "<table class='correctenglish' border='1' cellpadding='4' cellspacing='0' width='75%'>"; echo "<tr class='toprow'> <th>Stable</th> <th>Daily Profit</th></tr>"; // Print out result while($row = mysql_fetch_array($result)){ $link='/site/competitions/tipster'.$row[link]; echo "<tr><td>"; echo "<a href='$link'>"; echo $row[stable]; echo "</td><td>"; echo " £". $row[Profit]; echo "</td></tr>"; } echo "</table>"; ?> The current rseult is displayed here: http://www.further-flight.co.uk/site/competitions/tipster/aintr/sp/2010c.php If you click the individual links, the correct profit should be displayed at the top of the page. Any info gratefully received.
×
×
  • Create New...