Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing a SQL as array (easy solution?)

Status
Not open for further replies.

Thomas001

Programmer
Jun 24, 2004
29
US
Code:
$query = "SELECT subject FROM $uber_table";
$result = mysql_fetch_array(mysql_query($query));

Retrieve($result);


// Retrieve This Data and put into link form.
//	
function Retrieve($array)
{
  foreach($array as $value)
    Print("$value <br>");
}


Just trying to get this to print out all the items under the subject column and make them into links that will open up the rest of the file.

Problem #1
It prints out: (First being the first subject entered)
First
First

Problem #2
Making these into links that will open a new page displaying more info about the subject.

Thanks ^_-
 
Does this work?

Code:
$query = "SELECT subject FROM $uber_table";
$result = mysql_query($query);

Retrieve($result);

// Retrieve This Data and put into link form.
//    
function Retrieve($result)
{
  while ($row = mysql_fetch_array($result)) {
      echo '<a href="the_link.php">', $row['subject'], '</a><br>';
  }
}

*cLFlaVA
----------------------------
A polar bear walks into a bar and says, "Can I have a ... beer?"
The bartender asks, "What's with the big pause?
 
aye, got it =)




$query = "SELECT * FROM $uber_table";
$result = mysql_query($query);

Retrieve($result);
// Retrieve This Data and put into link form.
//
function Retrieve($array)
{
while ($rows = mysql_fetch_array($array))
{
printf("<a href='%s'>%s</a> <br>\n", $rows['ID'], $rows['subject']);
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top