HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
Creating links with MySQL query results
Post new topic   Reply to topic    HTML Help Forum Index -> PHP
View previous topic :: View next topic  
Author Message
Marius



Joined: 25 Apr 2007
Posts: 15
Location: Jhb, South Africa

PostPosted: Tue Jul 17, 2007 11:00 am     Creating links with MySQL query results Reply with quote

I have the following code that shows all my database tables....What i want to achieve is to make each result clickable which then link to edit, add & delete options for the table. I have googled and coulnd't find the answer to this.

How do i link the results?

Code:
   <?php $result = mysql_query( "SHOW TABLES" )
   or die("SELECT Error: ".mysql_error());
   $num_rows = mysql_num_rows($result);
   print "<h3>Tables</h3><P>";
   print "<table width=200 >\n";
   while ($get_info = mysql_fetch_row($result)){
   print "<tr>\n";
   foreach ($get_info as $field)
   print "\t<td><font face=verdana size=3/>$field</font></td>\n";
   print "</tr>\n";
   }
   print "</table>\n";

         ?>
Marius



Joined: 25 Apr 2007
Posts: 15
Location: Jhb, South Africa

PostPosted: Tue Jul 17, 2007 11:34 am     Reply with quote

...or even a link to a tutorial that covers this
mac_jsn



Joined: 21 Jun 2007
Posts: 6

PostPosted: Tue Jul 17, 2007 4:45 pm     Try these ones Reply with quote

Hi Marius

Though I myself is not an expert at the concern area, I always take help from some professional service providers, currently I am taking the services from http://www.techhelpformarketers.com for my current project. "They are an assembled team of Tech Professional with Extensive Experience in taking down IT task or IT technical problems giving you the Shortest Turnaround Time possible."

Hope it's helpful to you!

[mac_jsn]
Keikura



Joined: 24 Mar 2007
Posts: 167
Location: U.K.

PostPosted: Thu Jul 19, 2007 1:35 pm     Reply with quote

Ignore above post as it's by some spammer idiot.


Code:
<?php
   $result = mysql_query('SHOW TABLES') or die('SELECT Error: ' . mysql_error());
   
   $num_rows = mysql_num_rows($result);
   
   print "<h3>Tables</h3><br /><br />\n";
   print "<table width=200 >\n";

   while ($get_info = mysql_fetch_row($result))
   {
      print "<tr>\n";
      
      foreach ($get_info as $field)
      {
         print "\t" . '<td style="font-family:Verdana"><a href="table.php?table_name=' . $field . '">' . $field . '</a></td>' . "\n";
      }
      
      print "</tr>\n";
   }
   
   print "</table>\n";
?>


Click on a table name and it'll take you to table.php.

edit: Don't know why you need the foreach, SHOW TABLES will return just one column per row.
motherbee



Joined: 23 Oct 2007
Posts: 3

PostPosted: Tue Oct 23, 2007 8:42 pm     Reply with quote

Hi what is the "\t" for? I've used this script before and it works but I don't know what exactly the \t does.
Keikura



Joined: 24 Mar 2007
Posts: 167
Location: U.K.

PostPosted: Wed Oct 24, 2007 7:44 am     Reply with quote

Code:
echo "\t";


This will output a tab.

Code:
echo '\t';


Whereas this will output \t.

So in short it just outputs a tab same way \n puts in a newline in the source code.
motherbee



Joined: 23 Oct 2007
Posts: 3

PostPosted: Mon Oct 29, 2007 1:57 am     tnx Reply with quote

tnx. Smile
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> PHP All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial