I'd suggest a simple variable that increments with each iteration of the foreach loop. With something like the code below, you can access the number of the element with the counter variable.
// +--
// | Loop through the products.
// +--

$counter = 0; //Init the counter

foreach ($prodlist as $num => $prod) {
//Leave the below line at the top of the loop
$counter++; //Increment the counter with each product
//The counter starts at 1 and counts up

  // +--
  // | Print a table row opener.
  // +--

  print '<tr class="' . $trclass . '">' . $eol . $eol;

  // +--
  // | Print the tds and their content.
  // +--

  $prodname  = $this->xhtml_encode($prod['name']);
  $prodid    = $this->xhtml_encode($prod['id']);
  $prodlink  = $this->link_namespace($app,'prodshow',$prod['id']);
  $proddesc  = $this->xhtml_encode($prod['descshort']);
  $imgname   = $prod['imgsm'];

  $add_ok = 1;

  if (($prod['useinv']) && (!($prod['invlevel'] > 0))) {$add_ok = 0;}
  if ($prod['pricestatus'] == 'D') {$add_ok = 0;}

  $quandisp = 0;
  $quanform = $this->globals('khxc_cgi.' . $formid . '--' . $prodid . '--quantity');

  if (isset($quanform)) {$quandisp = $quanform;}

  if ($add_ok) {

       print '<td class="' . $tdclass . '">' . $eol . $eol;
       print '<label for="' . $formid . '--' . $prodid . '--quantity';
       print '" class="hidden">Quantity</label>' . $eol;
       print '<input class="khxc_formfield" type="text" name="';
       print $formid . '--' . $prodid . '--quantity';
       print '" id="' . $formid . '--' . $prodid . '--quantity';
       print '" value="' . $quandisp . '" size="5" maxlength="5" />' . $eol;
       print '</td>' . $eol . $eol;

  } else {

       print '<td class="' . $tdclass . '">&nbsp;' ...

Great! Please make sure to mark this thread as solved so other users know you don't require further assistance. Thanks :)

[QUOTE=PhilEaton;1317049]Yeah I saw that and changed it but in my original code it still didn't work. But it's all good now thanks a lot![/QUOTE]
No problem! Glad it's all fixed! :)

Well first, there's [URL="http://www.pdflib.com/"]PDFLib[/URL]. It's the popular choice (it's the library [URL="http://php.net/manual/en/book.pdf.php"]listed on PHP.NET[/URL]), but depending on usage, you might have to pay for it.
Some other notable choices a [URL="http://www.fpdf.org/"]FPDF[/URL] and [URL="http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf"]TCPDF[/URL].
There are also a few HTML2PDF converters such as [URL="http://www.digitaljunkies.ca/dompdf/"]dompdf[/URL], but if you aren't going to use the CSS property described in my link, they kind of defeat the purpose.
If you want help with the information provided in my original link, write back and I'll explain.

[QUOTE=britoniah3480;1316693]Lol because of this

$id = $_GET['id']; //you forgot to put the $id =

$username = "root";
$password = '123456';
$hostname = "localhost";
$db = mysql_connect($localhost, $username, $password)
or die ("Unable to connect to mySQL".mysql_error());

$del = "DELETE FORM newdbase WHERE id = $id";

$nres = mysql_query("$del);


you should try my site it might help you better :)[/QUOTE]

It also might be useful to note that once quotes are opened, they must be closed. But in your instance, quotes aren't necessary on this line.
$id = $_GET['id']; //you forgot to put the $id =

$username = "root";
$password = '123456';
$hostname = "localhost";
$db = mysql_connect($localhost, $username, $password)
or die ("Unable to connect to mySQL".mysql_error());

$del = "DELETE FORM newdbase WHERE id = $id";

$nres = mysql_query($del); //Much better

[QUOTE=chrishea;1317011]If you create the output as a Word file, you can tell it where you want the page breaks. I don't have the details handy but if you want to go that way I can dig up some details (I have done it but I would need to dig through a program to remember how).[/QUOTE]
If your users don't mind the hassle of opening a word document, you might consider a PDF for compatibility. I know a lot of people, myself included, hate them, but there are a bunch of PDF libraries for PHP, probably a lot more than there are word document libraries for PHP.

If you are using this code to download an image to [i]your[/i] computer (and not a server), I would use Python instead since it is suited for server side development as well as little scripts you want to schedule on your computer.
If you would like to continue with PHP, hielo has the right idea. Although I think cURL can handle FTP if you use an FTP URL like [url]ftp://user:pass@host:port[/url], but I'm not sure.
On second glance I noticed that you provided us with port 22, which happens to be the port for SSH (most likely for SFTP use). If you are using SSH/SFTP, you will need to use [URL="http://www.php.net/manual/en/ref.ssh2.php"]PHP's SSH functions[/URL].

You probably couldn't find anything because this is not a PHP specific feature. It only requires some HTML & CSS. I found [URL="http://www.chami.com/tips/internet/052898I.html"]this tip on adding printer-only page breaks[/URL]. Is this what you're looking for?

Props to you for using something other than MD5.
Now on to business. The basic way to validate a password stored in a database is to use a one way encryption such as SHA1. This involves hashing the password the user provides at registration and storing it in a database. To check if login credentials are valid, simply run the given password through the same hash function and compare the hashes. If the hashes are the same, the passwords match.

The code snippet you provided is not valid, nor does it validate. Please provide a better snippet that shows your problem.

Regarding for your original code, the reason why the IP displayed but you couldn't click the link is because you were missing an = between the href and the first quote. Try this:

If application/octet-stream works, why not use it? The only problem you mentioned is that Opera reports the file as 1.2MB instead of 1.12MB. This is probably not an error on your part. Opera usually rounds up all sizes to the tenths place so a file might be 12.56 MB but Opera will show it as 12.6 MB for succinctness. As long as the file downloads properly and reports the correct size when you view it in Explorer (as in viewing files on your computer, not Internet Explorer), why bother?

I would have done the same, but apparently, a space alone doesn't retain the same font size as the rest of the text in the table. If all else fails, insert some dummy text and style it with [icode]visibility: hidden;[/icode].

You can use [icode] [/icode] as an empty space in any empty table columns and rows. It's HTML's way of representing a space. In case you haven't noticed, a space along usually doesn't work, and multiple spaces (or a new line) do no appear. [icode] [/icode] is the answer to the multiple space (or single space alone) problem.

[icode]mysql_real_escape_string()[/icode] should be applied to any user generated content passed to MySQL to prevent SQL injections, but has no bearing on the limits on the text submitted (other than escaping characters).
The first thought that comes to mind is you aren't viewing the entire field. Try querying the DB, selecting the field, and outputting the description with PHP after inserting your description with your script. PhpMyAdmin never displays all the text if it exceeds a certain length. Usually you have to view the record individually to see the entire value of a long text field. When PhpMyAdmin truncates text, I believe it adds '...' after it to denote the truncation, but don't hold me to that.
Grab the description with PHP after inserting to verify, but I believe all the text will be there.

Sample of using [icode]mysql_real_escape_string()[/icode] to protect yourself from SQL injections, a dangerous hack that can expose and compromise data:
mysql_query("SELECT * FROM users WHERE username='".mysql_real_escape_string($_POST['username'])."' AND id='".mysql_real_escape_string($_POST['id')."'");

To grab the description, use the following:
//Conect to MySQL
//Then grab all the descriptions
$result = mysql_query("SELECT description FROM shortitem");
while($data = mysql_fetch_array($result)) {
echo $data['description']."

[QUOTE=detweiller;1313996]what does this mean:


and this:


They ([icode]<?=$something?>[/icode]) are PHP shorttags, and can be disabled on some server configurations. They basically an easier way of typing [icode]<?php echo $something; ?>[/icode] and while most don't recommend them, I will stubbornly continue to use them until their deprecation in PHP6! :)

The first one outputs the address of the page, so the form submits itself to the page that created it. The second outputs the id and name values from the MySQL database. The [icode]$data[/icode] variable is set to the values from each row of the MySQL query.

@ﻼim: Thanks! Back at ya!

@ev Sorry about that! I didn't see that you already answered the question. :P

[QUOTE=ﻼim;1315107]:) hey there PMC.

i do also have an idea about on what baudday's asking for.
programmers have different ways in solving the same problem, right?

mine's to adjudicate first if possible, the summary of a whole program code,
and after doing so that's when I'll start giving it a shot. Ϋ

it's also my way on knowing how good the person is in terms of his or her coding.
and just so you know i guess you're one of the best already. Ϋ

:icon_wink: mabuhay ka PMC![/QUOTE]
You have a valid point. Sometimes it is better to post code (as a rule, it's a good idea to post some for reference) and other times its not. Though, as the asker, its nicer if answers can be tailored to their exact needs. Salamat ﻼim!

baudday: If this thread has been solved, please make sure to mark it as solved so other users know that this thread does not need further clarification. Thanks! :D

britoniah3480 has a point. MySQL doesn't limit the number of rows in a table because that is not the purpose of a database. You can assume rows are empty if they aren't set (See britoniah3480's code above).
When inserting, you can ensure that there are still spaces by doing a quick check with PHP.
//Connect to MySQL
mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());

//Check if there are spaces left
$result = mysql_query("SELECT * FROM players WHERE team = '".$team."'");
if(mysql_num_rows($result) < 25) {
//Still spaces
} else {
//Team full

[QUOTE=ﻼim;1315091]hi there! Ϋ

would you mind displaying a part of your code that has relation with that?
that's to solve the problem faster.

:) thanks.[/QUOTE]
If you absolutely want it from baudday, you can ask for some code, but I found that baudday's description of what he/she was looking for was sufficient to come to a solution.

You could use [icode]ob_start()[/icode], include the file that creates the page (taking care to add any necessary GET variables to the include path as you would with a URL), and then store the contents of [icode]ob_get_contents()[/icode] in a variable. Demo below:

//Start output buffering
//Get the contents of the dynamic page
//Get the contents of the page through the OB
$contents = ob_get_contents();

//To demonstrate it works
echo '$contents = ';

//Sample dynamic content
echo 'This is dynamic. A = '.$_GET['a'];

If you need to send POST variables to the dynamic page you could use [URL="http://us.php.net/curl"]cURL[/URL] instead. A demo of this is below.

//Init curl and set some required options
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTANSFER, true);
//Set the URL (w/ get variables) and any post fields
curl_setopt($c, CURLOPT_URL, 'dynamic.php?a=10');
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, 'b=5');
//Get page contents and close cURL
$contents = curl_exec($c);

//To demonstrate it works
echo '$contents = ';

//Sample dynamic content
echo 'This is dynamic. A = '.$_GET['a'].', B = '.$_POST['b'];

Limits are based on characters and not by words. Longtext allows for 4GB of characters, so in theory it depends on how long your words are. It is possible to have ten words that contain more characters than 100 words. But I doubt this is the case. Some possible limitations could be fontend scripts, backend trimming, and/or server limitations.
It would really help to see some code. As a rule, I would always post some relevant code unless your question involves theory.

I know I'm kinda late to the party here, but if you prefer not to use JS (I'd use a library then like @ev said) here's the basic structure of populating a list with PHP and then returning results for that list:
//Connect to MySQL & Select DB
mysql_connect($host, $user, $pass) or die('There was an error with the database server. Please try again later.');
mysql_select_db($db) or die('There was an error with the database. Please try again later.');
<!docytype html>

PHP Popluate & Return Demo

Well it would take a little more work than that if you wanted true security. Slightly advanced authorization should look something like this. You should also look into [URL="http://skfox.com/2007/12/18/md5-hashes-and-salt/"]MD5 Salts[/URL].
mysql_connect($host, $user, $pass);

//If id & session are set validate them
if(isset($_COOKIE['id']) && isset($_COOKIE['session']) {
$result = mysql_query("SELECT * FROM users WHERE id='".mysql_real_escape_string($_COOKIE['id'])."' AND session='".mysql_real_escape_string($_COOKIE['session'])."'");
//Go to login page if id or session is invalid
if(mysql_num_rows($result) == 0) {
header('Location: login.php');
//Regenerate session id
$session = md5(mt_rand());
if(mysql_query("UPDATE users SET session='".$session."' WHERE id='".mysql_real_escape_string($_COOKIE['id'])."'")) {
setcookie('session', $session);
} else {
//Otherwise send to the login page
header('Location: login.php');

Well you'll need to find a way to get the short code SMS to communicate with your PHP script. I have no idea how to do this. When it comes to the PHP, it seems easy enough.
switch(strtolower($_GET['command'])) {
case 'pizza':
$r = mysql_query("SELECT * FROM pizza ORDER BY popularity DESC LIMIT 5");
if(mysql_num_rows($r) != 0) {
while($arr = mysql_fetch_array($r)) { echo $arr['name']; }
} else { echo "No pizzas found. Sry!"; }
This would work assuming you have already connected to your database and your table structure is similar to my little demo. You would also need to have texts to the number routed to your script, assuming the command parameter contains the contents of the text and the stdout is returned to the sender of the text message.

The basics of a user system involves three main parts.
[][B]Registration -[/B] The user provides details such as desired username, password, and email. Some verification should be done to make sure that the user names and emails are unique to that user. If they are, insert this information into a users table of your database. This table should include a unique ID, username, password (encrypted with the [icode]md5()[/icode] function, a one way hash), email, and session id. As an extra layer of security and to prevent spam you can filter for valid emails and send email verifications to ensure users give you valid addresses.
][B]Authentication -[/B] The user provides login details such as username and password or email and password. The username/email should be checked against the database. If it does exist, run the given password through an md5 hash to verify that the passwords match. From here, store the unique user id and a random session id as cookies on the users browser. To validate login, check to see if the unique id stored in the cookie matches a record in the table along with the session id. You can regenerate the sessionid for maximum security.
[*][B]Management -[/B] Something as simple as PhpMyAdmin can be used for user administration. You can update, delete, and add users with little to no extra work. If you prefer a more targeted admin panel, you can add advanced options that includes all of the above and other features such as banning by ...

Assuming that the downloads are routed through a PHP script, it should be simple enough to record user download data. The devil is in the database and how you store this information. Here's my recommendation:
You only need one table to store download information along with hit counts. I recommend three columns for tracking download numbers: A total downloads column, a weekly downloads column, and a monthly downloads column. When a user requests a file download, simply increment all three fields for that file by one.
You stats are simply a MySQL query away:
//Get total downloads
mysql_query("SELECT downloads FROM files WHERE id='".$id."'");

//Get weekly downloads
mysql_query("SELECT weeklyDownloads FROM files WHERE id='".$id."'");

//Get monthly downloads
mysql_query("SELECT monthlyDownloads FROM files WHERE id='".$id."'");
*Depending on what you name your columns

You will need CRON jobs to run once every Sunday and once at the end of every month. The weekly script should contain something along the lines of:
//Set all the files to a 0 weekly download count for the new week
mysql_query("UPDATE files SET weeklyDownloads=0");

As you can assume the monthly CRON will look something like this:
//Set all the files to a 0 monthly download count for the new month
mysql_query("UPDATE files SET monthlyDownloads=0");

**These all assume that you have already connected to MySQL and a DB, and perform the necessary [icode]mysql_fetch_array()[/icode]'s after if the query requires it.


phplover commented: Fantastic post made in helping me :) +1

Cringe Please, please, please [icode]mysql__real_escape_string()[/icode] any user given value before using it in a query. Without doing so you are putting yourself at high risk of SQL Injection!

Now on to your problem. I would check the query (it seems you've outputted it out as a comment) on the second line and verify that there isn't anything wrong with it.
It would be a tremendous help if you could provide us with the value of [icode]$_GET['id_proiect'][/icode] or the final query that produces this error.

Yeah, the MVC usually doesn't vary between frameworks; you only have to get used to the little quirks (such as CI Models) and extras. If your ambitious enough, you could design your own framework (something I've been working on as a side project), but thats a lot of work compared to downloading & learning CI!

Thanks Steve!
It is a great framework, though I am embarrassed to say that I haven't worked with it that much either. :D
Someone on the PHP form has to be a CI guru. If there isn't and vizz has a question about CI, I guess we have some reading to do...

[b]EDIT:[/b] It's been so long since I've been on Daniweb, I almost forgot how strange the smilies looked!

If I may add my ten cents, I believe that CodeIgniter.com has [URL="http://codeigniter.com/tutorials/watch/blog/"]a great 20 minute tutorial on creating a basic blog[/URL]. Not sure if you consider CI "a feature", but its a great way to create applications without having to worry about internals. This way you can learn the structure and required parts before you have to dive in and start from scratch. You can use some of the models ardav described and implement them in CI as a starting point. After you understand how everything fits together, then move on to starting from scratch.
If you are one of those dive-in-and-try-it people, then by all means, disregard the above and take a shot at it. Post any questions you may have here or in a new appropriate thread.

For the purists out there, I'm not endorsing CI as a start to PHP. I believe it's much better to learn and be comfortable with PHP basics & OOP before using a framework. In this case, I think a framework could help illustrate relationships and basic functionality.

All the Best,

[B]EDIT:[/B] No need to be rude LRNPHP. We're trying the best we can to help. If you didn't think you'd get help with your question, why did you post in the first place? All of us are volunteers here. Please respect that!

If you want a new window, I suggest looking into [URL="http://www.javascript-coder.com/window-popup/javascript-window-open.phtml"]JavaScript's window.open()[/URL]. It's ugly, outdated, and sometimes doesn't play nice with pop-up blockers, but it's what you asked for. Gunnarflex has a better solution for this as modal windows are much more elegant than pop-ups. You might also benefit from a neat trick such as replacing the original search box with several ones prefixed with refined options.
If this is not the solution to your problem, can you please explain your question. Exactly what are you looking for? I think we satisfied the need of the pop-up/modal window you asked for. Would you like help with the actual advanced search page?
We're not mind readers here! ;)
Help [I]us[/I] help [I]you[/I].