Jump to content

Petrushka

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Petrushka's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Many thanks for the helpful response, the data is now tabulated - where would I add the table details, such as width?
  2. Hi I've been working from some tutorials that are currently inaccessible due to the creator being out of bandwidth, and have hit a snag. I've had some assistance generating a section of code that displays an error message if the database cannot find anything to meet the user request. I've changed quite a lot of the code, and somewhere amongst this, I have lost the "bit" that puts all of the data into a tabular format. I've tried several things to get the right result, but no luck so far. Can anyone assist me, please? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head><title>Virtual Stud Book</title> <link rel="stylesheet" type="text/css" href="/style/style.css"/> </head> <?php include("../style/template.php");?> <body> <div id="main"> <?php $connection = mysql_connect("*****", "*****", "*****"); if (!$connection) {die('Could not connect: ' . mysql_error());} // Create database //if (mysql_query("CREATE DATABASE horses",$connection)) // { // echo "Database created"; // } //else // { // echo "Error creating database: " . mysql_error(); // } // Create table in my_db database mysql_select_db("virtualstu", $connection); // select record fields from database table and check for results $sql="SELECT * FROM horses WHERE breed='Arabian' AND gender='stallion' AND allowed='OK' ORDER BY points DESC"; if (!mysql_query($sql,$connection)) {die('Error: ' . mysql_error());} $mysql_result=mysql_query($sql,$connection); $num_rows=mysql_num_rows($mysql_result); if ($num_rows == 0) {echo "Sorry, we have no records for Arabian stallions.";} else { echo "<TR> <TH>Name</TH> <TH>Horse ID</TH> <TH>Player ID</TH> <TH>Type</TH> <TH>Points</TH> <TH>Goal</TH> <TH>Max Foals</TH> <TH>Breeding Style</TH> <TH>Fee</TH> </TR>"; // table population while ($row=mysql_fetch_array($mysql_result)) { $name=$row["name"]; $horse_id=$row["horse_id"]; $player_id=$row["player_id"]; $horse_type=$row["horse_type"]; $points=$row["points"]; $goal=$row["goal"]; $max_foals=$row["max_foals"]; $breeding_type=$row["breeding_type"]; $fee=$row["fee"]; // results echo " <TR> <TD>$name</TD> <TD>$horse_id</TD> <TD>$player_id</TD> <TD>$horse_type</TD> <TD>$points</TD> <TD>$goal</TD> <TD>$max_foals</TD> <TD>$breeding_type</TD> <TD>$fee</TD> </TR>"; } } </table> mysql_close($connection); ?> </body> </html>
  3. Brilliant! Works now, many thanks! Edit: Ooops. No, sorry jumped the gun.
  4. The php include is a strange one... I have another site with the same piece of code, hosted with the same people, works no problem. I have looked up the details, which are below: allow_url_fopen On On allow_url_include Off Off So I looked up on my host's support page how to change the allow_url_include to On: Bizarre. Have been playing with the count issue, and have managed to get rid of all error messages, though sadly, none of the breeds/counts show up either. $data = mysql_query("SELECT breed, COUNT(*) FROM horses WHERE gender='Mare' AND allowed='OK' GROUP BY breed") or die(mysql_error()); ?>
  5. Good afternoon. I was hoping for some advice or assistance on the two following points: a) I wish to have my banner and navigation system in a php include file. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head><title>Virtual Stud Book</title> <link rel="stylesheet" type="text/css" href="http://www.virtualstudbook.co.uk/style/style.css"/> </head> <?php include("http://www.virtualstudbook.co.uk/style/template.php");?> <body> <div id="main"> <b>Welcome to the Virtual Stud Book!</b> </div> </body></html> The result I get from the code above is: http://www.virtualstudbook.co.uk/index_test.php How can I correct this? Additionally, I have a table called horses, with current data as follows: http://www.virtualstudbook.co.uk/images/horses_table.jpg I would like to have a list of the breeds for each gender, showing how many results there are (if there are no results I'd still want the breed to show up with '0'). The current code is: <?php mysql_connect("*****", "*****", "*****") or die(mysql_error()); mysql_select_db("*****") or die(mysql_error()); $data = mysql_query("SELECT gender, COUNT(*) SELECT * FROM `horses` WHERE gender = 'mare' AND allowed='OK' GROUP BY breed;") or die(mysql_error()); ?> The current result is: http://www.virtualstudbook.co.uk/search/horse.php I'd appreciate any help.
  6. http://www.further-flight.co.uk/previews/current.php Question 1 I have in my database two columns that I'd like to use to produce links: url and date. The url column has the address I'd like to use, and the date the text I'd like to use for the link. I've seen a response to a similar question previously, and attempted to adapt this to my own code, but kept getting a blank page. I'd like to keep all of the other data with the links too. Question 2 Is there any way in which I can include the MySql column names on the pages where tables are produced of information from the database? Current code: <?php // Connects to your Database mysql_connect("******", "*******", "********") or die(mysql_error()); mysql_select_db("furtherfl") or die(mysql_error()); $data = mysql_query("SELECT * FROM race WHERE month='jul06' ORDER BY 'id'") or die(mysql_error()); Print "<table cellpadding=2 width=95%>"; while($info = mysql_fetch_array( $data )) { Print "<tr>"; Print "<td>".$info['date'] . "</td> "; Print "<td>".$info['race1'] . "</td> "; Print "<td>".$info['race2'] . "</td> "; Print "<td>".$info['race3'] . " </td>"; Print "<td>".$info['previewer'] . " </td></tr>"; } Print "</table>"; ?>
  7. I have managed to print my first set of results from my database. The last two columns, profit and balance are obviously numbers, and I'd like these two columsn only aligned to the right, so that the decimal points are in a uniform place. <?php // Connects to your Database mysql_connect("host", "database", "password") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); $data = mysql_query("SELECT * FROM tablename WHERE ref='2007-1' ORDER BY 'stable','date'") or die(mysql_error()); Print "<table cellpadding=2 width=100%>"; while($info = mysql_fetch_array( $data )) { Print "<tr>"; Print "<td>".$info['stable'] . "</td> "; Print "<td>".$info['date'] . "</td> "; Print "<td>".$info['time'] . "</td> "; Print "<td>".$info['track'] . " </td>"; Print "<td>".$info['horse'] . " </td>"; Print "<td>".$info['price'] . "</td> "; Print "<td>".$info['win'] . "</td> "; Print "<td align="right">".$info['profit'] . " </td>"; Print "<td>".$info['balance'] . " </td></tr>"; } Print "</table>"; ?> Thos returns the following error message: http://www.further-flight.co.uk/napsters/results.php How can I achieve this effect?
  8. I created a test web form, that successfully input the data into my test database. However, today I created a second form, added the layout code, putting the layout and mysql connection details into a php include code. These are the only changes I have made, apart from field names etc, but today, I get the following error message: I checked, but the nap hasn't been added to the database. I use the code I found on phpmac.com. It currently looks like this: <?php include("http://www.further-flight.co.uk/items/000183834.php"); ?> <?php include("http://www.further-flight.co.uk/items/04545387.php"); ?> <body> <div id="main"> <?php if (!isset($_POST['submit'])) { ?> <form action="" method="post"> <table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <td width="33%">Stable:</td> <td width="33%"><input type="text" name="stable"></td> <td width="33%"> </td> </tr> <tr> <td width="33%">Time:</td> <td width="33%"><input type="text" name="time"></td> <td width="33%">Please use 24 format i.e. 14:25</td> </tr> <tr> <td width="33%">Track:</td> <td width="33%"><input type="text" name="track"></td> <td width="33%"> </td> </tr> <tr> <td width="33%">Horse:</td> <td width="33%"><input type="text" name="horse"></td> <td width="33%">Please ensure names are spelt correctly!</td> </tr> </table> <input type="submit" name="submit" value="Submit!"> </form> <?php } else { $stable = $_POST['stable']; $time = $_POST['time']; $track = $_POST['track']; $horse = $_POST['horse']; mysql_query("INSERT INTO `napster` (stable, time, track, horse) VALUES ('$stable', '$time','$track', '$horse')"); echo "Your nap has been added to the database. Good Luck!"; } ?> </div> </body> </html> Any assistance in correcting this, and improving the code, would be very much appreciated. Here is a screenshot of the code with line numbers: http://www.further-flight.co.uk/napsters/withlinenumbers.jpg
  9. Hi Elaine I have been looking into this today too, I found this article useful: http://php.about.com/od/advancedphp/ss/mail.htm Have tried and tested, data is sent to the email OK. Hope it helps. Charlie
  10. I have just recently treated myself to a PHP/MySQL book for dummies, but obviously they were aiming for a higher standard of dummies than me, as I'm stuck. I am working on creating a form, which the inputted data being sent to a database (at least, that is the initial plan). I have recreated the example coding in the book, changing it to my data, but I receive an error message - when I look at the author's example, that doesn't appear to be working either! The full error message I got was: The sample of my code can be found here: http://www.equinefocus.co.uk/dummy/error.jpg I realise its likely to be a very simple goof, but any help sorting out this problem would be appreciated!
×
×
  • 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.