false Posted January 30, 2010 Report Share Posted January 30, 2010 (edited) Tātad problēma ir tāda, kā pievienojot faila aprakstu viņš nogriež kādu daļu no beigam, un indexā kur izvēlk to aprakstu rāda arī to nogriezto tekstu nevis pilno. sql CREATE TABLE IF NOT EXISTS `faili` ( `id` int(11) NOT NULL auto_increment, `who` varchar(255) collate utf8_unicode_ci NOT NULL, `fails` varchar(255) collate utf8_unicode_ci NOT NULL, `cikos` varchar(255) collate utf8_unicode_ci NOT NULL, `nosaukums` varchar(255) collate utf8_unicode_ci NOT NULL, `down` varchar(255) collate utf8_unicode_ci NOT NULL, `kategorija` varchar(255) collate utf8_unicode_ci NOT NULL, `apraksts` varchar(255) collate utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=3 ; add.php <p> <?php if(isset($_POST['submit'])){ $fails = $_POST['file']; $who = mysql_real_escape_string($id); $down = mysql_real_escape_string("0"); $nos = mysql_real_escape_string($_POST['nos']); $now = mysql_real_escape_string(date("d/m/Y")); $kat = mysql_real_escape_string($_POST['kategorija']); $apraksts = mysql_real_escape_string($_POST['apraksts']); mysql_query("INSERT INTO faili(who, fails, cikos, nosaukums, kategorija, apraksts, down) VALUES('$whom', '$fails', '$noww', '$nos', '$kat', '$apraksts', '$down')"); } ?> <br/><form action="" method="post"> <table><tbody> <tr><td>Fails:</td><td><input name="file" type="text"></td></tr><br /> <tr><td>Nosaukums:</td><td><input name="nos" type="text"><br/> <tr><td>Kategorija:</td><td> <select name="kategorija"> <?php $selekt_cat = mysql_query("SELECT * FROM kategorijas ORDER BY id ASC"); while($u = mysql_fetch_array($selekt_cat)){ ?> <option value="<?php echo $u['id']; ?>"><?php echo $u['nosaukums']; ?></option> <?php } ?> </select></td></tr><br /> <tr><td>Apraksts:</td><td><textarea id="apraksts" name="apraksts" rows="10" cols="50"> </textarea></td></tr> <tr><td></td><td><input type="submit" name="submit" value="Ielādet!" /></td></tr></tbody></table> </form></p> select.php <?php $sqldd = mysql_query("SELECT * FROM faili ORDER BY down DESC LIMIT 5") or die(mysql_error()); while($a = mysql_fetch_array($sqldd)){ ?> <div class="title"><h1><?php echo $a['nosaukums']; ?></h1> <a href="?p=file&id=<?php echo $a['id']; ?>">Vairāk informācijas</a></div> <div class="news_block"> <?php echo strlen($a['apraksts'])>450?substr($a['apraksts'],0,450).'...':$a['apraksts']; ?> </div> <?php } ?> Edited January 30, 2010 by false Quote Link to comment Share on other sites More sharing options...
waplet Posted January 30, 2010 Report Share Posted January 30, 2010 <?php echo strlen($a['apraksts'])>450?substr($a['apraksts'],0,450).'...':$a['apraksts']; ?> aizviet ar <?php echo $a['apraksts'];?> Quote Link to comment Share on other sites More sharing options...
false Posted January 30, 2010 Author Report Share Posted January 30, 2010 (edited) Atrisināju problēmu! Edited January 30, 2010 by false Quote Link to comment Share on other sites More sharing options...
2easy Posted January 30, 2010 Report Share Posted January 30, 2010 vsp tas apraksts nemaz nevarēja būt lielāks par 450, jo lauks ir definēts kā: apraksts varchar(255) NOT NULL tur drīzāk būtu vajadzīgs: apraksts text NOT NULL Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.