Jump to content

j3rmain3

Members
  • Posts

    40
  • Joined

  • Last visited

    Never

Everything posted by j3rmain3

  1. I have a table which has been setup in HTML, but now i need to store a rating system for the documents. I really do not want to copy all the data and enter it into mysql manually because there are about 50 documents. Is there a way i could place the data from the html table into mysql by using variables or something like that? Here is some sample coding incase someone will need coding to work with [size=9pt]Table Coding[/size] [code] echo "<tr>"; echo "<td>Players Name</td>"; echo "<td>Position</td>"; echo "<td>Goals</td>"; echo "</tr>"; echo "<tr>"; echo "<td>Jeremy Beadle</td>"; echo "<td>Striker</td>"; echo "<td>15</td>"; echo "</tr>"; [/code] [size=9pt]php[/size] [code] mysql_connect(****,****,****) or die ("ERROR:".mysql_error()); mysql_select_db(****) or die ("ERROR."mysql_error()); $query = "INSERT INTO ( This is where i have no idea what to write to import the data from the exisiting data in the html table into mySQL db )"; [/code] The table has already been setup in mysql. All i need to do is copy the info across. If more coding is need, just send a reply thanks j3rmain3
  2. I was wondering whether it is possible to create a rating system in PHP embedded within a HTML table? My situation is the client has a list of documents in a table with links. What the he wants is to be able to rate each document but they have already created the table in HTML and there are over 40 files so i dont really want to ask him to use MySQL because there is no way they will understand how to use it and storing the names in MySQL will take a long time. this is the layout i was considering using - with Radio Buttons ----------------------------- Document Title  | Rating        | ----------------------------- Document1.doc | 1o o o o o5 | ----------------------------- Document2.doc | 1o o o o o5 | ----------------------------- Document3.doc | 1o o o o o5 | ----------------------------- ------------- |  submit    | ------------- If i havent explained it properly please reply and i will try and answer as best i can thanks J3rmain3
  3. because i am having problems using the classes they have given to detail the charts. I am trying to add a label to the y axis but the classes do not make sense to me. If anyone has done this can you please show the code? Thanks J3rmain3
  4. You're a flipping genius. It works. thanks J3rmain3
  5. I had a earlier post about how i am creating dynamic charts using Libchart, PHP & MySQL. But i have another problem The coding will not retrieve the data from the database. I dont know what i am missing because i am used to displaying information using $player = $_POST['player']; but im not using a HTML form. I just want the data from the database to appear straight onto the graphs. Here is the coding..... [code]<?php include "libchart/libchart/libchart.php"; $host = "localhost"; $user = "root"; $pass = "mysql"; $db = "goals"; $connection = mysql_connect($host,$user,$pass) or die ("Unable To Connect To Server"); #connect to server mysql_select_db($db) or die ("Unable To Get Database"); #connect to database $query = "SELECT * FROM goals_data";#set up the query $result = mysql_query($query) or die ("ERROR in query: $query.".mysql_error());#run the query $numplayers = mysql_num_rows($result); #START CREATING THE CHART $chart = new VerticalChart(500, 500); for ($i=0; $i<=($numplayers-1);$i++) { ##echo "This is $l_name, and he has scored $goals goal(s)<p>"; $chart ->addPoint(new Point("$l_name","$goals")); } $chart ->setTitle("Goals Per Game"); $chart ->render("graphs/playerReport.png"); ?>[/code] Help !?! Thanks J3rmain3
  6. Yeah, i just realised that aswell Thanks alot for the help J3rmain3
  7. The error message still appears, and it still says the exact same thing. J3rmain3
  8. Sorry about that. Here is the coding [code]<html> <head> <title>Goals Per Game</title> <h3>Goals Per Game</h3> <meta http-equiv ="Content-Type" content="text/html; charset=ISO-8859-15" /> </head> <body> <?php include "libchart/libchart/libchart.php"; $host = "localhost"; $user = "root"; $pass = "mysql"; $db = "goals"; $connection = mysql_connect($host,$user,$pass) or die ("Unable To Connect To Server"); #connect to server mysql_select_db($db) or die ("Unable To Get Database"); #connect to database $query = mysql_query("SELECT * FROM goals_data"); #select all fields from table $result = mysql_query($query) or die ("ERROR in query: $query.".mysql_error());#run the query $numplayers = mysql_num_rows($query); #START CREATING THE CHART $chart = new verticalChart(); for ($i=0; $i<=($query);$i++) { $chart ->addPoint(new Point("f_name, $l_name", "$goals")); } $chart ->setTitle("Results From PowerDrive Field Test"); $chart ->render("graphs/powerDrive.png"); ?> <img alt="PowerDrive Report" src="graphs/PowerDrive.png" style="border: 1px solid black;" /> </body> </html> [/code] If you find more errors than just the problem i have stated can you please inform me. thery may be quite a bit because i was just choopping and adding things to try and get it to work Thanks J3rmain3
  9. I am trying to display dynamic graphs using LibChart, PHP and MySQL. I not very sure whether i could use LibChart with MySQL so i am trying to find out but when i program it all in PHP i get this error, and have no idea what is means. ERROR in query: Resource id #15.You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #15' at line 1 Can anyone help? J3rmain3
  10. Its working now Help was much appreciated. Thank You J3rmain3
  11. I have a table which is produced using a form. My problem is i want to sort the table in a descending order from the points field. I know the coding is [code]$sort = "select f_name, l_name, points from players ORDER BY points DESC";[/code] But i already have this query above it to show the table [code]$query = "select * from players";[/code] And it is not letting me run both queries. is it because it can only perform one? I even done an if statement but it still did not do anything. Do i have to do a loop? Thanks J3rmain3
  12. Cheers Ray, Its working now I knew it would be something simple. Your a legend !! J3rmain3
  13. I am trying to do something so simple but its not working and i have been staring at it for sooooooooooo long. I created a form in php and want to display the data in another php site. This is the coding i have used. [size=8pt][b]php form[/b][/size] [code]<html> <head> <title>Player Form</title> <h3>Player Form</h3> </head> <body> <?php if (!isset($_POST['submit'])) { ?> <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> Player First Name: <input type="text" name='f_name'><p> Player Last Name: <input type="text" name='l_name'><p> Team: <input type="text" name='team'><p> Position: <input type="text" name='position'><p> Points: <input type="text" size=2 name='points'> <b> /5</b><p> <input type="submit" name="submit" value="submit results"> </form> <?php } else { $host = "localhost"; $user = "root"; $pass = "mysql"; $db = "player_of_year"; $f_name = empty($_POST['f_name']) ? die ("ERROR: Enter In First Name") : mysql_escape_string($_POST['f_name']); $l_name = empty($_POST['l_name']) ? die ("ERROR: Enter In Last Name") : mysql_escape_string($_POST['l_name']); $team = empty($_POST['team']) ? die ("ERROR: Enter In The Team") : mysql_escape_string($_POST['team']); $position = empty($_POST['position']) ? die ("ERROR: Enter In Position") : mysql_escape_string($_POST['position']); $points = empty($_POST['points']) ? die ("ERROR: Enter In Your Rating") : mysql_escape_string($_POST['points']); $connection = mysql_connect($host,$user,$pass) or die ("Unable To Connect"); mysql_select_db($db) or die ("Unable to select database!"); $query = "INSERT INTO players ('f_name', 'l_name', 'team', 'position', 'points') values ('$f_name','$l_name','$team','$position','$points')"; echo "Your Rating Has Been Recorded"; echo "<p>"; echo "<a href=http://localhost/playertable.php><b>View Table<b>"; } ?> </body> </html>[/code] [size=8pt][b]php table[/b][/size] [code]<html> <head> <title>Player Of The Year</title> <h3>Player Of The Year</h3> </head> <body> <?php $host = "localhost"; $user = "root"; $pass = "mysql"; $db = "player_of_year"; $connection = mysql_connect($host,$user,$pass) or die ("Unable to Connect!"); mysql_select_db($db) or die ("Unable to select database!"); $query = "SELECT * FROM players"; $result = mysql_query($query) or die ("ERROR in query: $query.".mysql_error()); if (mysql_num_rows($result) > 0) { echo "<table cellpadding=10 border=1>"; echo "<tr>"; echo "<td><p align=center><b>First Name</td></b>"; echo "<td><p align=center><b>Second Name</td></b>"; echo "<td><p align=center><b>Team</td></b>"; echo "<td><p align=center><b>Position</td></b>"; echo "<td><p align-center><b>Points</td></b>"; echo "</tr>"; while ($row=mysql_fetch_row($result)) { echo "<tr>"; echo "<td><p align=center>".$row[1]."</td>"; echo "<td><p align=center>". $row[2]."</td>"; echo "<td><p align=center>".$row[3]."</td>"; echo "<td><p align=center>".$row[4]."</td>"; echo "<td><p align=center>".$row[5]."</td>"; echo "</tr>"; } echo "</table>"; } else { echo "No rows found!"; } mysql_free_result($result); mysql_close($connection); ?> <p> <a href=http://localhost/playerform.php><b>Return To From</b> </body> </html>[/code] If anyone can see why this would work can you please inform me because i have had enough of staring at it and not finding whats wrong with it. Thanks J3rmain3
  14. Hi I am trying to make the submit button in an HTML form display or disappear depending on a users ip address.I was testing this out by placing the ip address into a variable and then doing an if..else statement to change some text which worked well.Then i tried to use similar coding to show and hide the button but.. 1)was unable to find a hide/show function in php (dont think there is one after looking in the forum) 2)naming the button so its recognised as a a variable inside php when the page is first loaded. [size=6pt][b]html[/b][/size][code] coding for button -> <input type="submit" value="Button" name="button"> [/code] [size=6pt][b]php[/b][/size][code] <? coding to show/hide -> if($ip ==ipAddress){ #this is where i have no idea what to add to show/hide button; } else { #this is where i have no idea what to add to show/hide button; } ?> [/code] Any help would be much appreciated. J3rmain3
×
×
  • 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.