Jump to content

masgas

Members
  • Posts

    64
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

masgas's Achievements

Member

Member (2/5)

0

Reputation

  1. really good idea!! now I will think which is the best option to keep the array and give it a try! you've been of great help! thank you very much!
  2. great! now the question is: wouldn't the array be again= $array = ('one', 'two', 'three', 'four'); next time I load the page? how could I keep it: Array { [0] => two [1] => three [2] => four [3] => newvalue }
  3. Hi thank you for your reply! I think that's exactly what I need... I will read about the array_splice function and try to get the solution... the idea is having an array of four values all the time, insert one in the end and delete the first one... alway pulling the values from a db...
  4. Hi all! I'm trying to do something and I don't get it right... The idea is to have a first array with 4 different values, and each time the user clicks a form button: connect with the db, select one new value, delete the first from the existing array and insert the new value in the array... I've tried this code but no good result //connect with DB //pull new value results in => $tipoAvo = $row['tipoAvo']; /*Pre declared array $avos[0]="A320"; $avos[1]="B739"; $avos[2]="A319"; $avos[3]="B737"; Pre declared array */ //code $sum=sizeof($avos); if($sum<=4){ array_push($avos, $tipoAvo); reset($avos); $firstinarray = current($avos); $avos=array_diff($avos, array($firstinarray)); while (list($index, $values)= each ($avos)){ echo "<br>".$index." - ".$values;} } but it prints the same array, only inserting in the last line the new value: $tipoAvo. I guess that having the array predeclared is producing this result... but I don't get any ideas of how to avoid this... I would like to add it and delete the first, and so on each time the user cliks the form... so I have a 4 valued array that changes constantly... Thank you for your help, and ideas...
  5. ok... that worked just fine! thank you
  6. Hi this is what it echoes! SELECT RED FROM users WHERE nick = 'LEVC'SELECT GREEN FROM users WHERE nick = 'LEVC'SELECT BLUE FROM users WHERE nick = 'LEVC'SELECT BROWN FROM users WHERE nick = 'LEVC'
  7. I have this code. I get the message: Parse error: syntax error, unexpected T_STRING in /home/..../test.php on line 7 any ideas why??? $con = mysql_connect ('','','') or die ("no con"); @mysql_select_db ('$db_name') or die ('error DB'); $col = array('1'=>RED, '2'=>GREEN, '3'=>BLUE, '4'=>BROWN); foreach ($col as $key => $value){ $sql= "SELECT $value FROM users WHERE nick = '$_SESSION[nick]'"; $res= mysql_query($sql) or die mysql_errno($sql); while ($row=mysql_fetch_assoc($res)){ if ($row[$valor]!=''){$var= $row[$valor];} echo $var; } } ?>
  8. you see, this script is within a "paging text"... the variables I'm receiving the text is $string... I tried to use explode (); but I didn't manage to get it to work either...
  9. I use dreamweaver MX 2004 and it works great with apache and mysql... I go to the menu: site - manage sites - new site - and in the "local root folder" I have "C:\xampp\htdocs\" cause I'm working with xampp... this makes it work just fine with me...
  10. hi people! I have this function which prints an X numbers of characters, but I can't manage to make it not cut words in half... this is the last I tried and it prints the $maxlength=880 but the rest it doesn't print them... what am I doing wrong??? function substring($string, $start, $maxlength){ $strlength = strlen($string); $trows = ceil($strlength / $maxlength); for($i=0; $i<$trows; $i++){ $line = substr($string, $start, $maxlength); $lineB = substr($line, $start, strrpos($line, ' ')); } return $lineB; } thanks for your time!
  11. [color=orange]//This code selects an article from a DB and prints 250 chars at a time[/color] <?php $host="l"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name=""; // Database name $tbl_name=""; // Table name /*********** Start function *********************/ function substring($string, $start, $maxlength){ $strlength = strlen($string); // divide the length by the limit $trows = ceil($strlength / $maxlength); for($i=0; $i<$trows; $i++){ $lineB = substr($string, $start, $maxlength).""; $lineA = explode (" ", $lineB, 60); array_pop($lineA); $line = implode (" ", $lineA); } return $line; } /************** End Function ******************/ $maxlength = 250; if (!isset($_GET['page'])){   $page = 1;   $start = 0;   } else {   $page = $_GET['page'];   $start = ($page * $maxlength) - $maxlength;   } echo "<table width='300' height='455'>" ; mysql_connect("$host", "$username", "$password")or die("no conn DB"); mysql_select_db("$db_name")or die("no DB"); $sql="SELECT * FROM $tbl_name ORDER BY id DESC LIMIT 1"; $result=mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) {     $id = $row["id"];     $string = $row["detail"];   echo "<tr><td>".substring($string, $start, $maxlength)."...</td></tr>"; } echo "</table>"; ?> <?php $stringlength = strlen($string); echo "<p align=center>"; // Sets link for previous 25 and return to page 1     if($page != 1){         $pageprev = ($page - 1);         echo "<a href=\"".$_SERVER['PHP_SELF']."?page=1\">primera</a>&nbsp;&nbsp;";         echo "<a href=\"".$_SERVER['PHP_SELF']."?page=".$pageprev."\">previa</a>&nbsp;&nbsp;&nbsp;";     }else{         echo "&nbsp;&nbsp;&nbsp;";     } // Find out the total number of pages depending on the limit set $numofpages = ($stringlength / $maxlength); $totalpages = round($numofpages); // Loop thru all the pages and echo out the links     for($i = 1; $i <= $numofpages; $i++){         if($i == $page){             echo $i." ";         }else{             echo "<a href=\"".$_SERVER['PHP_SELF']."?page=".$i."\">".$i."</a> ";         }     } // Check for straglers after the limit blocks     if(($stringlength % $maxlength) != 0){         if($i == $page){             echo $i." ";         }else{             echo "<a href=\"".$_SERVER['PHP_SELF']."?page=".$i."\">".$i."</a> ";         }     } // Print out the Next 25 and Goto Last page links     if(($stringlength - ($maxlength * $page)) > 0){         $pagenext = ++$page;           echo "&nbsp;&nbsp;&nbsp;<a href=\"".$_SERVER['PHP_SELF']."?page=".$pagenext."\">siguiente</a>&nbsp;&nbsp;&nbsp;";           echo "<a href=\"".$_SERVER['PHP_SELF']."?page=".$totalpages."\">Ășltima</a>&nbsp;&nbsp;";     }else{         echo("&nbsp;&nbsp;&nbsp;");     } echo "</p>"; mysql_close(); ?>
  12. that did the trick!!!! only the next link is not working correctly! but the job was to get it printing right! I'll try to fix this next link and then post the full code for the rest of begginers like me... yo never know, someone may need something like this THANK YOU ALL
  13. aha! something like that! I've got a table with links on one side, and when I click on that link an article appears on the iframe... but this articles can have up to 20 paragraphs which is a lot for a 300 by 400 pixel box.. so the idea is page the text in the box... does it help?
  14. I'll explain myself a little better... I have a text, let's say 600 chars, and I want to page it because is too long for the space in te iframe I'm using... so I'd like to page the text... when I use the script from your last post it prints the whole message... how could I limit the text to 250 chars for example? thank you very much for your help
×
×
  • 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.