Jump to content

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());

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • 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.