Jump to content

[SOLVED] hyperlink and columns


spider22

Recommended Posts

Here the is my code ... I want to add hyper link in my title field

 

How I can do that? and is it possible to display data in the 2 columns instead of one ...

 

// Get all the data from the "example" table

$result = mysql_query("SELECT * FROM `jos_content` WHERE catid = '22' ORDER BY title ASC")

or die(mysql_error());

 

echo "<table border='1'

style='border-spacing:1px;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:10px;background-color:#E7E7E7;color:black;'><tr><th>Drama Review</th><th>Hits</th></tr>";

// keeps getting the next row until there are no more to get

$last_letter = null;

while($row = mysql_fetch_array( $result )) {

 

$current_letter = strtolower($row['title'][0]);

if($current_letter != $last_letter){//this means the first letter changed

echo "<tr><td colspan='2' style='background-color:black;color:white;'><center><b>$current_letter</b></center></td></tr>";

}

 

  // Print out the contents of each row into a table

  echo "<tr><td>";

  echo $row['title'];

  echo "</td><td>";

  echo $row['hits'];

  echo "</td></tr>";

 

$last_letter = $current_letter;//always change this so it's based on the previous

}

 

echo "</table>";

?>

Link to comment
Share on other sites

<?php

// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM `jos_content` WHERE catid = '22' ORDER BY title ASC")
or die(mysql_error());

echo "<table border='1'
style='border-spacing:1px;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:10px;background-color:#E7E7E7;color:black;'><tr><th>Drama Review</th><th>Hits</th></tr>";
// keeps getting the next row until there are no more to get
$last_letter = null;
while($row = mysql_fetch_array( $result )) {

$current_letter = strtolower($row['title'][0]);
if($current_letter != $last_letter){//this means the first letter changed
echo "<tr><td colspan='2' style='background-color:black;color:white;'><center>$current_letter</center></td></tr>";
}

   // Print out the contents of each row into a table
   echo "<tr><td>";
   echo "<a href='page.html'>";
   echo $row['title'];
   echo "</a>";
   echo "</td><td>";
   echo $row['hits'];
   echo "</td></tr>";

$last_letter = $current_letter;//always change this so it's based on the previous
}

echo "</table>";
?>

 

what exactly do you mean:

 

is it possible to display data in the 2 columns instead of one ...

 

are you talking about your html table?

Link to comment
Share on other sites

their just nesting tables to accomplish their layout, but you can do the same thing with your layout; you just need to format the html and/or css as you would like it to display. you could start by setting the width of your table and td tags.

 

Can you give sample code?

 

thanks

Link to comment
Share on other sites

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.