$_GET Problem!!!Anyone Help??
Posted: Mon Dec 20, 2004 5:45 pm
I'm trying to get a list of vinyl records which are in a particular genre. Im doing a query for the get_vinyl function where the genre_id is passed and the function can take this and display vinyls which have this id as a foriegn key. However what my scripts produce is nothing at all. It states that it has no vinyls to display when there are 3 vinyls in the funky house genre. Im using the $_GET but it's not working any help scripts are below.
Code: Select all
<?php
session_start();
require('page.inc');
require_once('shopping_cart_fns.php');
$genreid = $_GET['genre_ref'];
$name = get_genre_name($genreid);
$genreform = new Page();
$genreform -> Display();
display_main_menu();
$vinyl_array = get_vinyls($genreid);
display_vinyls($vinyl_array);
do_html_footer();
?>Code: Select all
<?php
require_once('useful_stock_fns.php');
//functions wrote by Manpreet Sandhu 18th Decemeber with reference from php and mysql web development by Luke Welling 2bd edition.
function do_html_footer()
{
?>
</body>
</html>
<?php
}
function do_html_URL($url, $cat_no)
{
?>
<td><font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif"><a href="<?php echo $url;?>"></font><?php echo $cat_no;?></a></font></td>
<?
}
function do_html_URL_genre($url, $title)
{
?>
<td><a href="<?php echo $url;?>"><?php echo $title;?></a></td>
<?php
}
function display_genres($genre_array)
{
if(!is_array($genre_array))
{
echo 'No Genres Currently Available<br />';
return;
}
{
?>
<table bgcolor="#7b9815">
<?
}
foreach ($genre_array as $row)
{
$url = 'show_genre.php?genre_ref='.($row['genre_ref']);
$title = 'Select';
{
?> <tr>
<td><font link="#7b9815" vlink="#7b9815" alink="#7b9815" color="#7b9815" size="2" face="Arial, Helvetica, sans-serif">
<?
}
echo '<td> </td><td> </td>';
echo'<td>';
echo $row['genre_description'];
echo '</td>';
echo '<td>';
do_html_url_genre($url, $title);
echo '</font></td>';
echo '</tr>';
}
echo '</table>';
if ($_SESSION['rank'] == '2'){
echo '<td valign="top"><table><tr><td>Admin Menu</td></tr>
<tr><td>Edit</td></tr>
<tr><td>delete</td></tr>
<tr><td>stock</td></tr>
</table></td>';
}
if ($_SESSION['rank'] == '1'){
echo '<td valign="top"><table><tr><td>Add Item</td></tr>
<tr><td>View Basket</td></tr>
<tr><td>delete</td></tr>
<tr><td>stock</td></tr>
</table></td>';
}
}
function get_genre_name($genreid)
{
$link_id = db_connect();
$query = "select genre_description from genres where genre_ref = $genreid";
$result = @mysql_query($query);
if(!$result)
return false;
$num_genres = @mysql_num_rows($result);
if ($num_genres ==0)
return false;
$result = mysql_result($result, 0, 'genre_description');
return $result;
}
function get_vinyls($genreid)
{
$link_id = db_connect();
$query = "select cat_no, title, artist_id from vinyls where genre_ref = $genreid";
$result = @mysql_query($query, $link_id);
if (!$result)
return false;
$num_vinyls = @mysql_num_rows($result);
if($num_vinyls == 0)
return false;
$result = db_result_to_array($result);
return $result;
}
function display_vinyls($vinyl_array)
{
if(!is_array($vinyl_array))
{
echo 'No vinyls Currently Available<br />';
return;
}
{
?>
<table bgcolor="#7b9815" border="1" bordercolor="FFFFFF">
<?
}
foreach ($vinyl_array as $row)
{
$url = 'show_vinyls.php?cat_no='.($row['cat_no']);
$title = $row['title'];
$artist = $row['artist_id'];
$cat_no = 'View';
{
?> <tr>
<td><font color="#7b9815" size="2" face="Arial, Helvetica, sans-serif">
<?
}
echo '<td>';
echo $row['cat_no'];
echo '</td>';
echo '<td>';
echo $row['artist_id'];
echo '</td>';
echo '<td>';
echo $row['title'];
echo '</td>';
echo '<td>';
do_html_url($url,$cat_no);
echo '</font></td>';
echo '<td>';
echo '</tr>';
}
echo '</table>';
if ($_SESSION['rank'] == '2'){
echo '<td valign="top"><table><tr><td>Admin Menu</td></tr>
<tr><td>Edit</td></tr>
<tr><td>delete</td></tr>
<tr><td>stock</td></tr>
</table></td>';
}
if ($_SESSION['rank'] == '1'){
echo '<td valign="top"><table><tr><td>Add Item</td></tr>
<tr><td>View Basket</td></tr>
<tr><td>delete</td></tr>
<tr><td>stock</td></tr>
</table></td>';
}
}
?>