SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Dec 2004
    Location
    Nottingham, UK
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $_GET Problem!!!Anyone Help??

    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.

    PHP Code:
    <?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();
        
    ?>
    the 'shopping_cart_fns.php' script

    PHP Code:
    <?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($result0'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>'
    ;
                                
                            }
                        
                                        
                        
                    }
                        
    ?>

  2. #2
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where is your query on the database. I am guesing its within the function get_genre_name() but you didnt show that function.

  3. #3
    $this->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Dec 2003
    Location
    Federal Way, Washington (USA)
    Posts
    1,524
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Um, I notice you said you had a problem with your get_vinyl function, but there's a function named get_vinyls. Is that what you meant?

    Just taking a cursory look at your code, there are a couple of things I'd do first off.

    In your 'shopping_cart_fns.php' script, find this statement:

    Code:
    $query = "select cat_no, title, artist_id from vinyls where genre_ref = $genreid";
    Add the following right after it:

    Code:
    die ($query);
    See if the query itself looks like what you're expecting. If so, copy/paste the query into your phpMyAdmin SQL command line and run it there to see if it works.

    Secondly, I would change this statement:

    Code:
    $result = @mysql_query($query, $link_id);
    to something like this instead:

    Code:
    $result = @mysql_query($query, $link_id) or die("There was a problem with this query.");
    That way, you get a message that lets you know there is a problem.

    I know this isn't exactly a solution for you, but I hope this helps.

    BTW, nice to see another vinyl enthusiast!
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    Showcase your music collection on the Web

  4. #4
    SitePoint Member
    Join Date
    Dec 2004
    Location
    Nottingham, UK
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cheers guys i sorted the problem i had not put quotes around $genreid inside my query. thanks for the help.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •