Jump to content
Killersites Forums

$array_test[0] returning nothing


ee92
 Share

Recommended Posts

Hi,

 

I've googled and searched through pages and tutorials to avoid bothering you guys with another question. But I've found nothing for this case. Can you please help?

 

I have this code:

 

<?php                                                        
                           $pass = $_GET['pass'];
                           $query="SELECT ID, Name, Description, Location, ListPrice, Price, Image FROM proclist WHERE ID = '$pass'";
                           $status=mysql_query($query) or die( "Query Failed.");    



                            $nt=mysql_fetch_array($status); ?>

                           <?php

                           $location = explode(",", "$nt[Location]");
                           $price = explode (",", "$nt[Price]");
                           $listprice = explode (",", "$nt[ListPrice]");

                           $count_values = sizeof($location);
                           $loop_count=0;

                           while ($loop_count < $count_values) {    ?>
                                                                                    
<?php echo '' . $location[$loop_count] . '';?>

Our Price:
                           <?php echo $price[$loop_count];?>
List Price:
                           <?php echo $listprice[$loop_count];
                           $loop_count++;            
                           }    

                           echo $location[0];
                           ?>

                           <



                           <?php 
                           $pass = $_GET['pass'];    

                           $location = explode(",", "$nt[Location]");

                           echo $location[$pass]; 
                           mysql_close($link);
                           ?>

 

Every thing works except at the end of the code. "echo $location[$pass];" works when $pass is equal 1 or 2 (displays the correct value) but NOT when $pass is equal to 0 (does not display anything).

 

Any ideas?

 

Thank you.

Link to comment
Share on other sites

$query="SELECT ID, Name, Description, Location, ListPrice, Price, Image FROM proclist WHERE ID = '$pass'";

 

asks your database to return results where the ID feild is equal to "pass", you can't have an id of zero if this is the primary key for the database, so there will be no results in your table that have an ID of zero so nothing will be displayed, same way for example there where 5 entries in your database and you set "pass" as 6 it would return nothing.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...