Jump to content

Changing variable length?, only want 15 characters of full desc into variable


luke777

Recommended Posts

Hi there :)

 

I'm new to php, still learning and I got stuck with this... I'd really appreciate any help, i've searched everywhere but without any success.

 

What I am doing is grabbing some table data and for each putting it into html code to display a list of games from the database

 

<?

$sql = mysql_query('SELECT * FROM `games` WHERE `authorsite`="yippigames" ORDER BY RAND() LIMIT 0, 3') or mysql_error();

 

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

                $rowname = $row["name"];

                $change = str_replace( " ", "-", $rowname);

 

                echo("<table class='gltable' cellpadding='0' cellspacing='0'><tr><td><a href='/game/".$row["id"]."/$change.html' rel='nofollow' class='gamelink'><img src='http://www.mysite.net/img/own/".$row["nameid"].".jpg' alt='".$row["name"]."' width='100' height='100' class='gamethumb' align='left' /></a><a href='/game/".$row["id"]."/$change.html' rel='nofollow' class='gamelink'>".$row["name"]."</a><br /><span class='gdesc'>".$row["desc"]."...</span></td></tr></table> \n");}

 

?>

 

 

Everything is displaying great, but my only problem is I only want 20 characters of the description to display otherwise theres too much text on the page for each game.

 

I just really need to make the ".$row["desc"]." in the code display just half of the full description.

 

Any ideas  ???

 

Any help is much appreciated!

 

Thanks Luke.

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.