Member Avatar for Puster

Hei!
I am worcking at the moment my website for my gaming clan http://www.physicgaming.com.

I'm working now on making a script that display results from the database (http://www.physicgaming.com/site/results.php) if you visit the site you see a big gray table, but this should be only 3 tables and not one big, what is it by?

Files I use:
http://pastebin.no/323q(index.php)
http://pastebin.no/323r -get_content.php (getting the data from database)
http://pastebin.no/323s -add new results
http://pastebin.no/323t -css code

Hope someone can help!
edit:
One question to, how can i have to colors on the rows? One on the first row and one on the other row?

Thanks for answeres!

Your code does not set the <table> and </table> tags.

Yes, that is why you have only one large table. If you want three, then you need to put the tags in your get_content code.

For the row colouring, see this: http://www.alistapart.com/articles/zebratables/

Member Avatar for Puster

thanks, fixed now :) www.physicgaming.com/site/results.php, but can you answer some more question, when i add a results i miss 2 slots, you see that in the frist one alle slots are text in, but in the two i add from my custom made script, the title of the row, does that i miss 11 and 12, what can i do to fix that?

12 is inside a p tag, instead of in the correct tr td I think.

Member Avatar for Puster
echo '<table><tr><th>'  . $row['team1'] . '</th>';
				echo '<th>'  . $row['team2'] . '</th></tr>';
				echo '<tr><td>'  . $row['spiller1'] . '</td>';
				echo '<td>'  . $row['spiller2'] . '</td></tr>';
				echo '<tr><td>'  . $row['spiller3'] . '</td>';
				echo '<td>'  . $row['spiller4'] . '</td></tr>';
				echo '<tr><td>'  . $row['spiller5'] . '</td>';
				echo '<td>'  . $row['spiller6'] . '</td></tr>';
				echo '<tr><td>'  . $row['spiller7'] . '</td>';
				echo '<td>'  . $row['spiller8'] . '</td></tr>';
				echo '<tr><td>'  . $row['spiller9'] . '</td>';
				echo '<td>'  . $row['spiller10'] . '</td></tr>';
				echo '<tr><td>'  . $row['spiller11'] . '</td>';
				echo '<td>'  . $row['spiller12'] . '</td></tr></table>';

it is in the right tags, the p tag is for the comment section, if the admin wants to add a comment after the clan war

Then the value must be empty, check your database. Perhaps a typo somewhere ?

Member Avatar for Puster

worcking now:) but how can i get differents colors on the rows?
<td class='red'></td> ?

Correct, just apply it to every other row.

Member Avatar for Puster

but i cant get my comment out from the database? what happend, have new codes now:
cms_results:

<?php

class physic_results {
	
	var $host;
	var $username;
	var $password;
	var $db;
	
	function connect() {
		$con = mysql_connect($this->host, $this->username, $this->password) or die(mysql_error());
		mysql_select_db($this->db, $con) or die(mysql_error());
	}
	
	function get_content($id = '') {
                     if($id != ""):
                            $id = mysql_real_escape_string($id);
                            $sql = " SELECT * FROM cms_results WHERE id = '$id'";
                            $return = '<p><a href="index.php"> Gå tilbake til startsiden</a></p>';                             
        else :
             $sql = "SELECT * FROM cms_results";
        endif;
       
        $res = mysql_query($sql) or die(mysql_error());
       
        if (mysql_num_rows ( $res ) != 0) :
            while ( $row = mysql_fetch_assoc ( $res ) ) {
                echo '<h1><a href="results.php?id=' . $row['id'] . '">' . $row['title'] . '</a></h1>';
				echo '<h3>' . $row['result'] . '</h3>' ;
				echo '<h5>' . $row['comment'] . '</h5>' ;
				echo '<table><tr><th class="top">'  . $row['team1'] . '</th>';
				echo '<th class="top">'  . $row['team2'] . '</th></tr>';
				echo '<tr><td class="green">'  . $row['spiller1'] . '</td>';
				echo '<td class="red"'  . $row['spiller2'] . '</td></tr>';
				echo '<tr><td class="green">'  . $row['spiller3'] . '</td>';
				echo '<td class="red">'  . $row['spiller4'] . '</td></tr>';
				echo '<tr><td class="green">'  . $row['spiller5'] . '</td>';
				echo '<td class="red">'  . $row['spiller6'] . '</td></tr>';
				echo '<tr><td class="green">'  . $row['spiller7'] . '</td>';
				echo '<td class="red">'  . $row['spiller8'] . '</td></tr>';
				echo '<tr><td class="green">'  . $row['spiller9'] . '</td>';
				echo '<td class="red">'  . $row['spiller10'] . '</td></tr>';
				echo '<tr><td class="green">'  . $row['spiller11'] . '</td>';
				echo '<td class="red">'  . $row['spiller12'] . '</td></tr></table>';
            }
         else :
            echo '<p> Oisann! Her har det visst skjedd en feil, beklager så mye </p>';
        endif;
       
        echo $return;
	}
    }
	?>

Add Results:

<?php

class physic_add_results {
	
	var $host;
	var $username;
	var $password;
	var $db;
	
	function connect() {
		$con = mysql_connect($this->host, $this->username, $this->password) or die(mysql_error());
		mysql_select_db($this->db, $con) or die(mysql_error());
	}
	function add_content($p) {
		$title = mysql_real_escape_string($p['title']);
		$team1 = mysql_real_escape_string($p['team1']);
		$team2 = mysql_real_escape_string($p['team2']);
		$spiller1 = mysql_real_escape_string($p['spiller1']);
		$spiller2 = mysql_real_escape_string($p['spiller2']);
		$spiller3 = mysql_real_escape_string($p['spiller3']);
		$spiller4 = mysql_real_escape_string($p['spiller4']);
		$spiller5 = mysql_real_escape_string($p['spiller5']);
		$spiller6 = mysql_real_escape_string($p['spiller6']);
		$spiller7 = mysql_real_escape_string($p['spiller7']);
		$spiller8 = mysql_real_escape_string($p['spiller8']);
		$spiller9 = mysql_real_escape_string($p['spiller9']);
		$spiller10 = mysql_real_escape_string($p['spiller10']);
		$spiller11 = mysql_real_escape_string($p['spiller11']);
		$spiller12 = mysql_real_escape_string($p['spiller12']);
		$comment = mysql_real_escape_string($p['comment']);
		$result = mysql_real_escape_string($p['result']);
		
		
		if(!$title):
			
			if(!$title):
				echo "<p>Det trengs en overskrift!</p>";
			endif;
				
				echo '<p><a href="add_results.php">Prøv Igjen!:)</a></p>';
			else:
				 $sql = "INSERT INTO cms_results VALUES (null, '$title', '$team1', '$team2', '$spiller1', '$spiller2', '$spiller3', '$spiller4', '$spiller5', '$spiller6', '$spiller7', '$spiller8', '$spiller9', '$spiller10', '$spiller11', '$spiller12',  '$comment', '$result')";
				 $res = mysql_query($sql) or die(mysql_error());
				 echo "Result is saved!";
			endif;
		}
}
		?>

Why doesnt result and comments show up?

Did you fix this, because I see them before the table.

Member Avatar for Puster

Yes i fixed it, just two tinghs more and im finished!
How can i get 1,2,3,4,5,6 in the firs row? and 6,7,8,9,10,11,12 in the second row?
And way isnt tow rows showing?
And how can i get the border aroun the title to be just around the title?

1. Do you always have 12 items ?
2. Not all tags are closed properly.
3. In the css, change H1 style to display: inline. I think that should fix it.

For 1. If you first load all items in an array, then you can loop the first six, and display the first and the seventh (second and eight) in the same row.

Member Avatar for Puster

what do you mean?

Sorry, I see you only have one result. You just need to re-order your $row[spiller] and put them in a different order.

Member Avatar for Puster

do you have an example?

Just move the spiller1 through spiller12 in your code. 1 through 6 should be after tr td, the other ones should be before /td /tr

Member Avatar for Puster

Can you pleas explain it with an example, i dont understand what you mean..

if (mysql_num_rows ( $res ) != 0) :            
while ( $row = mysql_fetch_assoc ( $res ) ) {                
  echo '<h1><a href="results.php?id=' . $row['id'] . '">' . $row['title'] . '</a></h1>';
  echo '<h3>' . $row['result'] . '</h3>' ;
  echo '<h5>' . $row['comment'] . '</h5>' ;
  echo '<table><tr><th class="top">'  . $row['team1'] . '</th>';		
  echo '<th class="top">'  . $row['team2'] . '</th></tr>';
  echo '<tr><td class="green">'  . $row['spiller1'] . '</td>';
  echo '<td class="red"'  . $row['spiller7'] . '</td></tr>';
  echo '<tr><td class="green">'  . $row['spiller2'] . '</td>';
  echo '<td class="red">'  . $row['spiller8'] . '</td></tr>';
  echo '<tr><td class="green">'  . $row['spiller3'] . '</td>';
  echo '<td class="red">'  . $row['spiller9'] . '</td></tr>';
  echo '<tr><td class="green">'  . $row['spiller4'] . '</td>';
  echo '<td class="red">'  . $row['spiller10'] . '</td></tr>';
  echo '<tr><td class="green">'  . $row['spiller5'] . '</td>';
  echo '<td class="red">'  . $row['spiller11'] . '</td></tr>';
  echo '<tr><td class="green">'  . $row['spiller6'] . '</td>';
  echo '<td class="red">'  . $row['spiller12'] . '</td></tr></table>';
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.