So I am trying to create an array which contains all letters of the alphabet as well as the term 'Quality'. I would like these values to appear in a horizontal row so the user can choose a letter and a $_GET['letter'] command will show the results of the query. Here is what I have at the moment.

<?php
include("connect.php");

$sql = "SELECT jargonterm FROM jargon WHERE letter = 'A'";  
//echo $sql."<br>"; $result = mysql_query($sql) or die(mysql_error());
echo $result."=result<br> "; while($row=mysql_fetch_array($result))
{ // NOTE this one ABOVE the echo //echo "result found!"; //echo $row[0]; echo '<a href="jargon_complete_details.php?letter='. urlencode($row[0]) .'">'. $row[0] .'</a><br><br>';
//echo $row[1] .'<br><br>'; } ?>

    use
    $str = "A,B,C,D,E,..........,Quality";
    $strarray = explode(",", $str);
    u will get a array of each alphabet and "quality";

      hmm... you can also use:

      $array = range('A', 'Z');
      $array[] = 'Quality';

        I made a golf-dicitionary on a site a long while ago. Here is how I did it:

        <?php
        // array of alphabet using the range() function:
        $letters = range('a','z');
        
        // loop through the letters:
        foreach($letters as $value)
        {
        	echo '<a href="?page=dictionary&amp;letter=' . $value . '">' . strtoupper($value) . '</a> |' . "\n";
        }
        
        // grab letter from URL
        if (isset($_GET['letter']))
        {
        	$letter = trim(strtolower($_GET['letter']));
        } 
        else { 
        	$letter = 'a'; 
        }
        
        // page heading
        echo '<h2>' . strtoupper($letter) . '</h2>';
        
        // required db connection info
        require("../inc/db.inc.php");  
        
        // Connect to mysql and select db		
        $my_db = connecting2_db();
        
        // grab start from the URL
        if(isset($_GET['start']))
        {
        	$start = trim($_GET['start']);
        } 
        
        else { 
        	$start = 0; 
        }
        
        // db Query
        $sql = "SELECT * FROM dictionary WHERE alpha = '$letter' ORDER BY id ASC LIMIT " . $start . ", 5";
        
        // Connect or die
        $result = mysql_query($sql, $my_db) or db_mysql_die();
        
        // if there are no results for this letter:
        if (mysql_num_rows($result) <= 0)
        {
        	echo '<p>Sorry. No items were found for the letter: <strong>' . $letter . '</strong>.</p>';
        }
        
        // else, there are results:
        else {
        
        while ($row = mysql_fetch_array($result))
        {
        	echo '<p><span class="bold">' . $row['term'] . ':</span> ' . $row['definition'] . '</p>' . "\n";
        }
        }
        
        // previous and next links
        $query = "SELECT count(*) as count FROM dictionary WHERE alpha = '$letter'";
        
        $result = mysql_query($query,$my_db);
        
        $row = mysql_fetch_array($result);
        
        $numrows = $row['count'];
        
        // Previous Link.
        if($start > 0 || $numrows > ($start + 10))
        {
        	echo '<p style="border-top:solid 1px #3a3936;margin:5px;">';
        }
        if($start > 0)
        {
        	echo '<a href="' . $_SERVER['PHP_SELF'] . '?start=' . ($start - 5) . '&amp;letter=' . $letter . '">Previous</a> ';
        }
        
        // Next Link.
        if($numrows > ($start + 10))
        {
        	echo '<a href="' . $_SERVER['PHP_SELF'] . '?start=' . ($start + 5) . '&amp;letter=' . $letter . '">Next</a>';
        }
        echo '</p>';
        
        // end SQL session
        mysql_close();
        ?>
        

        (I am not sure I would do it this way now, but I hope it helps you out a little...)

          laserlight wrote:

          hmm... you can also use:

          $array = range('A', 'Z');
          $array[] = 'Quality';

          🙂

            cheers guys - I have utilised your ideas and come up with the following solution which works fine:

            <?php 
            include("connect.php");
            // array of alphabet using the range() function: 
            $array = range('A', 'Z'); 
            $array[] = 'Quality'; 
            
            
            // loop through the letters: 
            foreach($array as $value) 
            { 
                echo '<a href="?page=dictionary&amp;letter=' . $value . '">' . strtoupper($value) . '</a> |' . "\n"; 
            } 
            
            // grab letter from URL 
            if (isset($_GET['letter'])) 
            { 
                $letter = trim(strtolower($_GET['letter'])); 
            } 
            else { 
                $letter = 'a'; 
            } 
            ?>	
            </div></td>
                    </tr>
                    <tr>
                      <td height="364"><div id="Layer2" style="position:absolute; width:603px; height:49px; z-index:13; left: 353px; top: 273px;">
                        <?php
            
            if (isset($_GET['letter'])) { 
            include("connect.php");
            
            $course = mysql_real_escape_string($_GET['letter']); 
            $sql = "SELECT jargonterm FROM jargon WHERE letter = '$letter'"; 
            
            $result = mysql_query($sql) or die(mysql_error());  
            echo $result."=result<br> "; while($row=mysql_fetch_array($result))
            { // NOTE this one ABOVE the echo //echo "result found!"; //echo $row[0]; echo '<a href="jargon_complete_details.php?jargonterm='. urlencode($row[0]) .'">'. $row[0] .'</a><br><br>'; } } ?>
              Write a Reply...