Jump to content

[SOLVED] Table Troubles


futurewii

Recommended Posts

Hey, Im trying to get all the entries from my MySql table to show up here under different tables depending on the "console" value, the value thing works but it only shows one and they all are moved down? any thoughts?

 

 

Page of Problem...

http://www.futurewii.com/?page=videos/index

 

Script...

<div id="content">
<h2><span lang="en-gb">Video Database..</span></h2>

		<br /><br />
<h2>Nintendo Wii</h2>
<br />
<table width="400">
<tr style='font-size:12px;' bgcolor="#c0c0c0">
	<th>Game Title</th>
	<th>Video Type</th>
<?php
include "includes/conn.php";
$query_count = "SELECT * FROM videos WHERE console='wii'"; 
$rs = mysql_query($query_count) or die("Problem with the query: $query_count<br>" . mysql_error());
$row = mysql_fetch_assoc($rs); {
		print "<tr style='font-size:12px;'>";
		print "<td><a href='?page=videos/view&id=".$row['id']."'>";
		echo $row['title'];
		print "</a></td>";
		print"<td>".$row['type']."</td>";
		print "</tr>";

	}

?>

<br /><br />
<h2>Gamecube</h2>
<br />
<table width="400">
<tr style='font-size:12px;' bgcolor="#c0c0c0">
	<th>Game Title</th>
	<th>Video Type</th>
<?php
include "includes/conn.php";
$query_count = "SELECT * FROM videos WHERE console='ngc'"; 
$rs = mysql_query($query_count) or die("Problem with the query: $query_count<br>" . mysql_error());
$row = mysql_fetch_assoc($rs); {
		print "<tr style='font-size:12px;'>";
		print "<td><a href='?page=videos/view&id=".$row['id']."'>";
		echo $row['title'];
		print "</a></td>";
		print"<td>".$row['type']."</td>";
		print "</tr>";

	}

?>
<br /><br />
<h2>Virtual Console</h2>
<br />
<table width="400">
<tr style='font-size:12px;' bgcolor="#c0c0c0">
	<th>Game Title</th>
	<th>Video Type</th>
<?php
include "includes/conn.php";
$query_count = "SELECT * FROM videos WHERE console='vcg'"; 
$rs = mysql_query($query_count) or die("Problem with the query: $query_count<br>" . mysql_error());
$row = mysql_fetch_assoc($rs); {
		print "<tr style='font-size:12px;'>";
		print "<td><a href='?page=videos/view&id=".$row['id']."'>";
		echo $row['title'];
		print "</a></td>";
		print"<td>".$row['type']."</td>";
		print "</tr>";

	}

?>
<br /><br />
<h2>Other Videos</h2>
<br />
<table width="400">
<tr style='font-size:12px;' bgcolor="#c0c0c0">
	<th>Game Title</th>
	<th>Video Type</th>
<?php
include "includes/conn.php";
$query_count = "SELECT * FROM videos WHERE console='oth'"; 
$rs = mysql_query($query_count) or die("Problem with the query: $query_count<br>" . mysql_error());
$row = mysql_fetch_assoc($rs); {
		print "<tr style='font-size:12px;'>";
		print "<td><a href='?page=videos/view&id=".$row['id']."'>";
		echo $row['title'];
		print "</a></td>";
		print"<td>".$row['type']."</td>";
		print "</tr>";

	}

?>

<br />

Link to comment
https://forums.phpfreaks.com/topic/112260-solved-table-troubles/
Share on other sites

while($row = mysql_fetch_assoc($rs)) {
print "<tr style='font-size:12px;'>";
print "<td><a href='?page=videos/view&id=".$row['id']."'>";
echo $row['title'];
print "</a></td>";
print"<td>".$row['type']."</td>";
print "</tr>";
}

 

You didn't put the code in a loop so it just printed the first result then skipped the next code segment.

 

The above code should work.

 

One more thing, how come you're mixing print and echo statements when they are ultimately the same function (there is a difference but that difference isn't utilised here).

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.