Jump to content

[SOLVED] Layout SQL results


unitedintruth

Recommended Posts

Okay, so I'm more of a newbie today than most days, just when you think you are figuring it out.

 

I am trying to make a links directory, I got my form working to insert the data into the database, now I am trying to get the results to layout in a table.

 

My only fields are Name, Description, and URL and I can't seem to get it to layout.

 

Can someone please help me a little bit?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/151277-solved-layout-sql-results/
Share on other sites

Change the connection to how you like it as well as the query and the table styles

 

<?php

  mysql_connect($host, $user, $pass);
  mysql_select_db($database);

  $query = mysql_query("SELECT * from tablename", $con) or die(mysql_error());

  echo '<table border="0">';

  echo '<tr><th>Link</th><th>Description</th></tr>';

  while ($row = mysql_fetch_array($query))
  {
      
      echo '<tr>';
      echo '<td><a href="'.$row['URL'].'">'.$row['Name'].'</a></td>';
      echo '<td>'.$row['Description'].'</td>';
      echo '</tr>';
      
  }

  echo '</table>';

?>

The only things I changed was the

 

host, user, password

database

 

and the tablename in the select statement and I am getting the following error

 

Warning: mysql_query(): 7 is not a valid MySQL-Link resource in /home/garrett/public_html/links.php on line 155

 

line 155 is

 

$query = mysql_query("SELECT * from links", $con) or die(mysql_error());

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.