Jump to content

Help with a summary script


Fallen_angel

Recommended Posts

Hi I need a bit of help with a script I have

I what I basicly want to do is have a short summary pulled from one of my database fields
the database field itself can have 10,000 charictors in it , however I only want to return 250 charictors to be returned  so that it can be used as a description in the bellow search script

I have looked around but I can't find a way that I can simply just limit the number of charictors the results return . I know it can be done because I have seen it done but just don't know how to do it


bellow is my code so far , anyone that can help I would really apreciate it

[code]
<?php
//Connect To database
include "connect.php";
$id = $_GET['id'];
//collects Data
$data=mysql_query(" SELECT * FROM DB where s_id='$id' ")
or die(mysql_error());
Print "<table class='print_list_alpha' border=0px style=border-bottom:1px;>" ;
while ($info= mysql_fetch_array($data) )
{
Print "<tr><td><img src=./uploads/mini_thumbs/".$info['img']."></td><td><table><tr><td><a href=../guide/report.php?id=".$info['s_id']."><b>".$info['name']."</b></a></td><tr><td> ".$info[notes'] ."</td></tr></table>";
}
Print "</table>" ;
?>[/code]

Thanx to anyone that can help
Link to comment
Share on other sites

Ok well i think I have it semi working I think however I may be calling it incorrectly ,

would I still use ".$info['fieldname']."  to call the contained info ?  or does it change because I used a substring ,

atm All I get is no summary at all , no errors and everything else loads ok so I'm guessing it's the way I am calling in on the page

I have also replaced the * with the specific fields that I need thankyou very much for that extra tip :)

here is what my code looks like now
[code]
<?php
//Connect To database
include "connect.php";
$id = $_GET['id'];
//collects Data
$data=mysql_query("SELECT SUBSTRING(description,0,250) s_id,name,rating,img FROM DB where name LIKE '$id%'ORDER by 'name'")
or die(mysql_error());
Print "<table class='print_list_alpha' border=0px style=border-bottom:1px;>" ;
while ($info= mysql_fetch_array($data) )
{
Print "<tr style=background-color:#E9F3EA;><td><img src=./uploads/mini_thumbs/".$info['img']."></td><td background-color=#E9F3EA><table><tr><td><a href=../strainguide/page.php?id=".$info['s_id']."><b>".$info['name']."</b></a></td><tr><td> ".$info['notes'] ."</td></tr></table>";
}
Print "</table>" ;
?>
[/code]

thanx in advance for any help people can give  :)
Link to comment
Share on other sites

He he I feel silly but I got it workign now for any one that wants to see the script it is now as follows

[code]<?php
//Connect To database
include "connect.php";
$id = $_GET['id'];
//collects Data
$data=mysql_query("SELECT s_id,name,rating,img,description FROM strains where name LIKE '$id%'ORDER by 's_name'")
or die(mysql_error());
Print "<table class='print_list_alpha' border=0px style=border-bottom:1px;>" ;
while ($info= mysql_fetch_array($data) )
{
Print "<tr style=background-color:#E9F3EA;><td><img src=./uploads/mini_thumbs/".$info['img']."></td><td background-color=#E9F3EA><table><tr><td><a href=../strainguide/page.php?id=".$info['s_id']."><b>".$info['name']."</b></a></td><tr><td> " ;
Print substr($info['description'],0,250); Print "</td></tr></table>";
}
Print "</table>" ;
?>
[/code]

thankyou very much for your assistance :)
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.