-
PHP Issue
When i try to echo out of the database, it echos nothing with no error.
PHP Code:
<?php
if(!$_GET[category]){
echo('
<a href="products.php?category=soccer">Soccer Trophies</a>
<br />
');
}else{
$query = "SELECT * FROM catalogue WHERE category = '$_GET[category];'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result) or die(mysql_error());
echo("
<table border='1'>
<tr>
<td><img src='images/".$row[item_number].".JPG'></td>
</tr>
<br>
<tr>
<td>Item Number: ". $row['item_number']."</td>
</tr>
</tr><br>
<tr><td>".$row[price]." GBP (Great Brittish Pounds)</td></tr>
<br>
</table>
<br>
");
}
?>
-
PHP Code:
<?php
if( $_GET[category] == "" )
{
echo '<a href="products.php?category=soccer">Soccer Trophies</a> <br />
';
}
else
{
$query = mysql_query( "SELECT * FROM `catalogu`e WHERE category = '{$_GET[category]}'" );
while( $row = mysql_fetch_array( $result ) )
{
echo '<table border="1">
<tr>
<td><img src="images/' . $row[item_number] . '.JPG"></td>
</tr>
<br />
<tr>
<td>Item Number: ' . $row['item_number'] . '</td>
</tr>
<br />
<tr>
<td>' .$row[price] . " GBP (Great Brittish Pounds)</td></tr>
<br />
</table>
<br/>
';
}
}
?>
-
Ryan's was incorrect so:
PHP Code:
<?php
if( $_GET[category] == "" )
{
echo '<a href="products.php?category=soccer">Soccer Trophies</a> <br />
';
}
else
{
$query = mysql_query( "SELECT * FROM `catalogue` WHERE category = '{$_GET[category]}'" );
while( $row = mysql_fetch_array( $result ) )
{
echo '<table border="1">
<tr>
<td><img src="images/' . $row[item_number] . '.JPG"></td>
</tr>
<br />
<tr>
<td>Item Number: ' . $row['item_number'] . '</td>
</tr>
<br />
<tr>
<td>' .$row[price] . ' GBP (Great Brittish Pounds)</td></tr>
<br />
</table>
<br/>
';
}
}
?>
-
-
Its still blank.Im confused.
-
Make sure the tables & rows exists.
-
PHP Code:
<?php
if( $_GET[category] == "" )
{
echo '<a href="products.php?category=soccer">Soccer Trophies</a> <br />
';
}
else
{
$query = mysql_query( "SELECT * FROM `catalogu`e WHERE category = '{$_GET[category]}'" );
while( $row = mysql_fetch_array( $query ) )
{
echo '<table border="1">
<tr>
<td><img src="images/' . $row[item_number] . '.JPG"></td>
</tr>
<br />
<tr>
<td>Item Number: ' . $row['item_number'] . '</td>
</tr>
<br />
<tr>
<td>' .$row[price] . " GBP (Great Brittish Pounds)</td></tr>
<br />
</table>
<br/>
';
}
}
?>
-
Cant Edit Last Post,
Sorry, i was tired when i looked at that and that wont work either lol,
This will work:
PHP Code:
<?php
if( $_GET['category'] == "" ){
echo '<a href="products.php?category=soccer">Soccer Trophies</a> <br />';
}else{
$category = $_GET['category'];
$query = mysql_query( "SELECT * FROM `catalogue` WHERE category = '$category'" );
while( $row = mysql_fetch_array( $query ) ){
echo '<table border="1">
<tr>
<td><img src="images/' . $row['item_number'] . '.JPG"></td>
</tr>
<br />
<tr>
<td>Item Number: ' . $row['item_number'] . '</td>
</tr>
<br />
<tr>
<td>' .$row['price'] . ' GBP (Great Brittish Pounds)</td></tr>
<br />
</table>
<br/>';
}
}
?>
-
-
Try this and tell me the error which it says:
PHP Code:
<?php
if( $_GET['category'] == "" ){
echo '<a href="products.php?category=soccer">Soccer Trophies</a> <br />';
}else{
$category = $_GET['category'];
$query = mysql_query( "SELECT * FROM `catalogue` WHERE category = '$category'" ) or die("MySQL Error: <br>".mysql_error());
while( $row = mysql_fetch_array( $query ) ){
echo '<table border="1">
<tr>
<td><img src="images/' . $row['item_number'] . '.JPG"></td>
</tr>
<br />
<tr>
<td>Item Number: ' . $row['item_number'] . '</td>
</tr>
<br />
<tr>
<td>' .$row['price'] . ' GBP (Great Brittish Pounds)</td></tr>
<br />
</table>
<br/>';
}
}
?>