# Pulling up database fields in a list (with links)

**URL:** <https://www.phphelp.com/t/pulling-up-database-fields-in-a-list-with-links/11114>\
**Category:** MySQL database\
**Created:** [March 30, 2008, 4:42pm UTC](https://www.phphelp.com/t/pulling-up-database-fields-in-a-list-with-links/11114 "2008-03-30T16:42:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![PromptSpace](https://www.phphelp.com/letter_avatar_proxy/v4/letter/p/ce7236/32.png) [@PromptSpace](https://www.phphelp.com/u/PromptSpace)\
**Post date:** [March 30, 2008, 4:42pm UTC](https://www.phphelp.com/t/pulling-up-database-fields-in-a-list-with-links/11114/1 "2008-03-30T16:42:14Z")

</div>

This was originally a code that i used with an older version of php, and i changed it a bit to make it work with the new version, but as you can tell, it’s not working.

I have been struggling with this code for a few days now, and i can’t figure it out. Anyone see anything wrong with the following code? My database fields are: show, season, episode, code…

[code]\<?  
if(!isset($\_GET[‘show’])) {  
echo “You did not select a show!”;  
exit;  
}  
$show=$\_GET[‘show’];  
?\>

PlayMode.TV - Watch \<? echo $row['show']; ?\>  

* * *
\<?php $dbhost = 'localhost'; $dbuser = '\*\*\*\*\*\*\*\*\*'; $dbpass = '\*\*\*\*\*'; $conn = mysql\_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'playmode\_shows' or die ('Error: '.mysql\_error ()); mysql\_select\_db($dbname); $query = "SELECT `episode`, `show`, `code` FROM `shows` WHERE `episode`='$episode' ORDER BY `episode`"; $result = mysql\_query ('SELECT \* FROM shows') or die ('Error: '.mysql\_error ()); while($row = mysql\_fetch\_array($result, MYSQL\_ASSOC)); ?\>

&nbsp;&nbsp;&nbsp;&nbsp;\<? echo $row['episode']; ?\>

\<? mysql\_close($conn) or die ('Error: '.mysql\_error ()); ?\>[/code]

I’m trying to use that code to pull up a list of my shows in my db with the link [http://www.playmode.tv/index.php?page=shows&show=Scrubs](http://www.playmode.tv/index.php?page=shows&show=Scrubs)

Also, this is the code for the page that I’m trying to link to, which is also not working…

[code]\<?  
if(!isset($\_GET[‘episode’])) {  
echo “You did not select an episode!”;  
exit;  
}  
$title=$\_GET[‘episode’];  
?\>

\<?php $dbhost = 'localhost'; $dbuser = '\*\*\*\*\*\*\*\*\*'; $dbpass = '\*\*\*\*\*'; $conn = mysql\_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'playmode\_shows'; mysql\_select\_db($dbname); $query = "SELECT `episode`, `code` FROM `shows` WHERE `episode`='$episode'"; $result = mysql\_query($query); while($row = mysql\_fetch\_array($result, MYSQL\_ASSOC)) ?\>
  
\<? echo $row['code']; ?\>
\<? mysql\_close($conn); ?\>[/code]

---

<div class="post-metadata">

**Author:** ![peg110](https://www.phphelp.com/letter_avatar_proxy/v4/letter/p/bb73d2/32.png) [@peg110](https://www.phphelp.com/u/peg110)\
**Post date:** [April 2, 2008, 2:56pm UTC](https://www.phphelp.com/t/pulling-up-database-fields-in-a-list-with-links/11114/2 "2008-04-02T14:56:00Z")

</div>

If you manually (using something like phpMyAdmin) run the query SELECT \* FROM shows on the database playmode\_shows what does it return?

---

<div class="post-metadata">

**Author:** ![PromptSpace](https://www.phphelp.com/letter_avatar_proxy/v4/letter/p/ce7236/32.png) [@PromptSpace](https://www.phphelp.com/u/PromptSpace)\
**Post date:** [April 4, 2008, 2:00am UTC](https://www.phphelp.com/t/pulling-up-database-fields-in-a-list-with-links/11114/3 "2008-04-04T02:00:43Z")

</div>

I’m not sure if this is what you wanted but: SQL query: Documentation

SELECT `shows`.`show`  
FROM shows  
WHERE (  
`shows`.`show` Scrubs  
)  
ORDER BY `shows`.`show` ASC  
LIMIT 0 , 30

MySQL said: Documentation  
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘Scrubs)  
ORDER BY `shows`.`show` ASC  
LIMIT 0, 30’ at line 3

Or I tried entering what you told me and got nothing…:

Showing rows 0 - 1 (2 total, Query took 0.0004 sec)  
SQL query:  
SELECT \*  
FROM shows  
LIMIT 0 , 30

(No results i guess?)

---

<div class="post-metadata">

**Author:** ![PromptSpace](https://www.phphelp.com/letter_avatar_proxy/v4/letter/p/ce7236/32.png) [@PromptSpace](https://www.phphelp.com/u/PromptSpace)\
**Post date:** [April 4, 2008, 2:05am UTC](https://www.phphelp.com/t/pulling-up-database-fields-in-a-list-with-links/11114/4 "2008-04-04T02:05:42Z")

</div>

I uploaded a screenshot of my results if the text was unclear…

Edit: I get the same results if i use `show` instead of \*

[attachment deleted by admin]

---

<div class="post-metadata">

**Author:** ![Zyppora](https://www.phphelp.com/letter_avatar_proxy/v4/letter/z/76d3ee/32.png) [@Zyppora](https://www.phphelp.com/u/Zyppora)\
**Post date:** [April 4, 2008, 10:04am UTC](https://www.phphelp.com/t/pulling-up-database-fields-in-a-list-with-links/11114/5 "2008-04-04T10:04:33Z")

</div>

> [@""PromptSpace""](#):
>
> SELECT `shows`.`show`  
> FROM shows  
> WHERE (  
> `shows`.`show` Scrubs  
> )  
> ORDER BY `shows`.`show` ASC  
> LIMIT 0 , 30
> 
> MySQL said: Documentation  
> #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘Scrubs)  
> ORDER BY `shows`.`show` ASC  
> LIMIT 0, 30’ at line 3

You missed a = between shows.show and Scrubs.

---

<div class="post-metadata">

**Author:** ![PromptSpace](https://www.phphelp.com/letter_avatar_proxy/v4/letter/p/ce7236/32.png) [@PromptSpace](https://www.phphelp.com/u/PromptSpace)\
**Post date:** [April 6, 2008, 2:31am UTC](https://www.phphelp.com/t/pulling-up-database-fields-in-a-list-with-links/11114/6 "2008-04-06T02:31:01Z")

</div>

I didn’t generate that code. I typed what i wanted to pull up in the form and it generated it for me. Does that mean my phpmyadmin is messed up?
