FlashCreations 20 Posting Whiz

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;' . …
FlashCreations 20 Posting Whiz

Sure it is. As long as you don't have any includes or extensions that could access this global. My guess would be that you won't be including and malicious scripts on your site intentionally, so with the details you gave, I would say you're safe!
-PhpMyCoder

FlashCreations 20 Posting Whiz

You don't, well technically you can, but there's a better way in my mind to store avatars. Simply upload them to a writeable directory (and be sure to check their name for validity: ensure to remove and null characters) and rename them to the user's name. You can also rewrite the writeable directory so that the URL to access a user's picture.

If you absolutely insist on storing an image in a MySQL database, check out this tutorial on PhpRiot.

FlashCreations 20 Posting Whiz

Yes,
If you could send me the full files that would help in the debugging process. Also, would you mind sending over a few more samples of the CSS styles & URL's so I can ensure I've tailored the Regexes to work with everything you throw at them.
Cheers,
PhpMyCoder

FlashCreations 20 Posting Whiz

It all depends on what you are looking for. Java has the best implementation of OOP, but requires the JRE (Java Runtime Environment) to be installed for applications to work. It should be used for cross-OS programs or to server web content (JSP).
PHP is best suited for web applications since most of its features are targeted towards database and user interaction. It's my choice of language for dynamic web content (hence the name PhpMyCoder).
C++ is just a good language to know, period. It gives you, the developer, a lot of power and control over your applications, but sometimes requires you to define functionalities that other higer-level-languages might have by default. That said C++ has it's applications. You could use it for a Windows Program, but it wouldn't be my first choice for developing an online forum or blog. Also note, that C++ is very popular as pretty much every application has some part of it written in it or C.

FlashCreations 20 Posting Whiz

I think the question is not Flash/PHP vs. AJAX/PHP. Since Flash also designs content I would argue the debate is actually Flash vs. HTML5/CSS/JavaScript. The latter is an inseparable and pretty much unbeatable trio.
Besides the open source benefits of HTML, CSS, and JavaScript, the big seller for most font end developers and designers is that they are one-hundred percent free. Some don't have the $500 to drop on products from Adobe to develop Flash content for their site.
The other big reason for HTML/CSS/JavaScript over Flash in my mind is that HTML/AJAX/JavaScript has a fall back. AJAX (or JavaScript) is only meant to extend the experience of a static HTML page, so when it's not supported, the browser just falls back to links and static content contained in the HTML. Flash, on the other hand, has no easy fall back. If a user doesn't have Flash, they might see a message similar to Youtube's "Javascript is not enabled or you need to install Flash" message. To create a fall back for a fully Flash site you would need to code it in HTML/CSS, which defeats the purpose of creating it in Flash in the first place.

As I've made it quite obvious by now, I'm on the HTML/AJAX side of the argument, but there are some valid points for Flash. Currently, there is no open source video format supported by HTML5 that includes live video or audio, so until the day that becomes available, sites like …

FlashCreations 20 Posting Whiz

The limits are based on characters and not with words. LongText allows 4GB of characters, so in theory it depends on how long your words are. It is possible to have ten words that contain characters more than 100 words. But I doubt it is. Some possible restrictions could fontend backend script trimming and / or server limitations.

This sounds awfully familiar, almost like this was a post I wrote. In fact it is (the first post in this thread after the author's post).

"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."

Besides the thread is already solved, garryamin. Maybe you can contribute to another thread.

FlashCreations 20 Posting Whiz

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

FlashCreations 20 Posting Whiz

It's also important to note that overuse (Multiple requests made in under a couple seconds) of websites such as Yahoo, Google, or Bing can get your IP banned from accessing their services. Furthermore, if you are on a shared IP your chances of being blocked are higher since there is a chance of multiple cURL connections to one site in a short amount of time.

FlashCreations 20 Posting Whiz

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!

No problem! Glad it's all fixed! :)

FlashCreations 20 Posting Whiz

Well first, there's PDFLib. It's the popular choice (it's the library listed on PHP.NET), but depending on usage, you might have to pay for it.
Some other notable choices a FPDF and TCPDF.
There are also a few HTML2PDF converters such as dompdf, 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.

FlashCreations 20 Posting Whiz

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());
	mysql_select_db('mynewdbase');

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

$nres = mysql_query("$del);

?>

you should try my site it might help you better :)

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.

<?php
$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());
	mysql_select_db('mynewdbase');

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

$nres = mysql_query($del); //Much better
?>
FlashCreations 20 Posting Whiz

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).

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.

FlashCreations 20 Posting Whiz

If you are using this code to download an image to your 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 ftp://user:pass@host:port, 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 PHP's SSH functions.

FlashCreations 20 Posting Whiz

You probably couldn't find anything because this is not a PHP specific feature. It only requires some HTML & CSS. I found this tip on adding printer-only page breaks. Is this what you're looking for?

FlashCreations 20 Posting Whiz

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.

FlashCreations 20 Posting Whiz

Google Adsense is nice, free too. It's not PHP, but it should work.

FlashCreations 20 Posting Whiz

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:

<a href="<?= $ip ?>"><?= $ip ?></a>

Also notice that since you have shorttags enabled I used shortened syntax to print variables. It removes the need for print or echo in short, one-line variable outputs and will be compatible with PHP (with shorttags enabled) until 6.0.0.

FlashCreations 20 Posting Whiz

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?

FlashCreations 20 Posting Whiz

The function will not internally parse it.
But lets say i have one php page : http://www.mysite.com/register.php
And i use file_get_contents('http://www.mysite.com/register.php') then html source will be returned by file_get_contents function.

Simply we can have 'View Source' type of functionality.

From the PHP.net documentation:
"file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance."

If the file is stored locally, file_get_contents() basically does the following:

$fp = fopen($file, "r");
$contents = fread($fp, filesize($file));
fclose($fp);

It will not execute any PHP contained within the file. For any PHP code within the file to execute you will have to use output buffering and include the file, as mschroeder suggested, or grab the file with cURL (which is similar to grabbing the source from a browser). By far, including the file is faster since it doesn't require any socket connections like cURL does.

FlashCreations 20 Posting Whiz

Well the most basic way in PHP would be to simply use the header function to report the 301 and then notify the user of the new location. That can be done like so:

<?php
//301 Redirect
header('HTTP/1.1 301 Moved Permanently'); 
header('Location: http://sub.domain.com/index.php?product='.urlencode($_GET['product'])); 
?>

Though, if you want every query in the form of index.php?product= to be redirected to the subdomain, htaccess is your best choice. If you have it enabled, use it over PHP if at all possible since the rules in it are executed before PHP parses and runs any scripts. What you are looking for can be done with:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index.php?product=(.*)$ http://sub.domain.com/index.php?product=$1 [L,R=301]
</IfModule>

EDIT: DaniWeb bug above? I set the code type in the above tag to htaccess. Are unknown types being defaulted to PHP or is there some kind of language detector (if so, .ht files look nothing like PHP source)?

FlashCreations 20 Posting Whiz

The problem probably doesn't involve the user's internet settings, but you never know. Why not try something like this to process the form:

<?php
//Protect email's reader by sanitizing all data
array_walk($_POST, 'htmlentities');

//Ensure Taxed Field is filled
if($_POST['Taxed'] != 'No' && $_POST['Taxed'] != 'Yes') {
    //Send user back to form asking for taxed field
    //Don't fill the form because it is impossible for a user to not submit
    //An answer to taxed. Only a hacker or exploiter would be able to do this
    header('Location: http://www.n-v-m.co.uk/Booking.html');
    die('No taxed option selected'); //You can change this text if you want
}

//Fields to grab
$fields = array('company', 'name', 'phonenum', 'email', 'vman', 'vreg', 'colladd', 'collconname', 'collconnum', 'deladd', 'delconname', 'delconnum', 'collectiondt', 'deliverydt', 'Taxed', 'billadd', 'custordnum', 'addcom');

//Construct message
$message = '';
for($x = 0; $x < count($fields); $x  ) {
    $message .= $_POST[$fields[$x]];
    if($x != count($fields) - 1) {
        $message .= '|';
    }
}

//Send message and redirect to Thank You Page
mail('info@n-v-m.co.uk', 'Order from '.$_POST['company'].' ('.$_POST['name'].')', $message, "From: NVM Booking Form\r\n");
header('Location: http://www.n-v-m.co.uk/Thankyou.html');
?>
FlashCreations 20 Posting Whiz

A few years back I made a simple Pagination Class w/ documentation. I'm not trying to pedal my script, but if want to take a look you can find it on my site.

FlashCreations 20 Posting Whiz

then just get rid of the last part where you are appending the time: $dd = substr($d_var['weekday'],0,3) .','. $d_var[mday] .' '.substr($d_var[month],0,3).' '. $d_var[year];

That was my first thought, but then I assumed the solution wasn't as simple as that. I don't know though, it might be. In which case, we all would look like total idiots for making it so difficult. :P

FlashCreations 20 Posting Whiz

You will need to edit your theme (this can be done in Wordpress) and find your footer.php file. Locate the appropriate code, in this case some kind of heading for a bookmarking list, and remove it. Save the file and refresh a blog page. Your undesired content should be gone!
Cheers,
PMC

FlashCreations 20 Posting Whiz

To be absolutely sure, you could split the string into the date and time part with explode() :

//Split it and eliminate the time
list($date,) = explode(' ', $date);
//Show the result
echo $date;

On the off change that the date format does not add leading zeros to one digit months/days (I believe the standard does), this would be one way around that and would still work with two digit months and/or days.

FlashCreations 20 Posting Whiz

Since you're new we'll cut you some slack! But if you noticed there is a pinned thread at the top of the forum that talks specifically about this error. Be sure to check out this great thread. It's bound to have your solution!

FlashCreations 20 Posting Whiz

Props to you for having the most creative greeting I've seen on DaniWeb! :D
Ahoy Captain Syphilis (Sounds a little strange, but anyway),
I'd suggest registering socket_close() as a shutdown function after the child makes a connection. This way any early exits will close the socket before ending the script. I'm not sure if this will fix your problem, but give it a shot. It's my best guess at the current time.

//Create the close socket function
function closeSock() {
    //Grab the global sock variable & close it
    global $sock; //Make this $socket if in the parent
    socket_close($sock);
}

//Register yee function as when the user abandons ship
register_shutdown_funtion('closeSock');

Also, while were on that subject, why not close the register the socket_close() function as a shutdown function in the parent, just for good measure.
Good Luck Mate,
PhpMyCoder

FlashCreations 20 Posting Whiz

So is it solved? If not, can you give us a sample of some of the URL's you try? The URL you gave in the first post should work fine and did work fine when I tried it. If it doesn't, have you set your charset to the appropriate one with the meta charset tag?

FlashCreations 20 Posting Whiz

I'm no Wordpress expert, but I'll give it a shot. My guess is that your functions are being called before Wordpress outputs a header (such as a redirect). This will cause problems because headers are sent after the first character of content has been outputted. It might help to actually echo the values instead of end the PHP and insert them in the file. Try something like this:

<?php
function test() {
    global $whatever;
    echo '<b>some html here</b><em>and lets add that global: '.$whatever.'</em>';
}
?>

Instead of:

<?php
function test() {
    global $whatever;
?>
<b>some html here</b><em>and lets add that global: <?= $whatever ?></em>
<?php
}
?>
FlashCreations 20 Posting Whiz

Php is a fully supported form and picture uploaded.

I assume you mean PHP fully supports image uploading via a form, which is does. Links to PHP.net docs and article on Tizag are above.

FlashCreations 20 Posting Whiz

Ahh yes, my suggestion only satisfied the aesthetic requirements, but doesn't seem that logical. I would instead use CSS like Darz mentioned and style each row to be a certain height.

table tr {
    height: 18px;
    line-height: 18px;
}

Best,
PhpMyCoder

FlashCreations 20 Posting Whiz

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 visibility: hidden; .

FlashCreations 20 Posting Whiz

:D yeah, you're really good at samples- no second thought with that PHP man (former PMC man). Ϋ

Never gotten that before, but PHP Man works too. I'll have to make note of that somewhere on the new site! :)

FlashCreations 20 Posting Whiz

You can use &nbsp; 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. &nbsp; is the answer to the multiple space (or single space alone) problem.

FlashCreations 20 Posting Whiz

Yes it will! Php.net also has a few pages on file uploading. You may want to look at them too!

FlashCreations 20 Posting Whiz

mysql_real_escape_string() 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.

EDIT
Sample of using mysql_real_escape_string() 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']."<br>\n";
}
FlashCreations 20 Posting Whiz

this just proves that i still have a lot to learn! :$
i haven't used any of the functions here.
really nice to know all this.

thanks PMC. Ϋ

You're welcome! :D

As you learn more about PHP, you'll see a lot of these useful features like cURL. As it says in my signature, be sure to take some time to look over some of the listed extensions on the PHP.net documentation. You'll discover some other great extensions such as the GD image library. Best of luck with your future PHP scripts!
-PMC

FlashCreations 20 Posting Whiz

What do you mean by blank bookings? Is the email you receive blank or are the spaces where data should be blank?
Do you enforce the filling of required fields via PHP? You can also enforce this via JavaScript (it doesn't seem like you do), but you should always enforce on the backend too! Enforcing the filling of a field is as simple as:

//Init error array
$errors = array();

//Check that fields are filled with valid data
if(!isset($_POST['name'])) {
   $errors[] = '<p>Please enter your name</p>';
}
//etc.
if(count($errors) != 0) {
    echo implode("\n", $errors);
    //Output the form
    exit();
}

//Send the email

@ﻼim: Did I mention how much I love code examples? :P

EDIT On second glance there is an easier way to validate the form in one script. Here is some sample code:

//Init error array
$errors = array();

//Check if form has been submitted
if($_POST['submit_button_name'] == 'Submit Button Value') {
    //Check that fields are filled with valid data
    if(!isset($_POST['name'])) {
       $errors[] = '<p>Please enter your name</p>';
    }
    //etc.
    if(count($errors) != 0) {
        break;
    }

    //Send the email
    //Redirect to thank you
    exit();
}

echo implode("\n", $errors);
//Output the form
FlashCreations 20 Posting Whiz

what does this mean:

action="<?=$_SERVER?>"

and this:

value="<?=$data?>"><?=$data

They ( <?=$something?> ) are PHP shorttags, and can be disabled on some server configurations. They basically an easier way of typing <?php echo $something; ?> 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 $data variable is set to the values from each row of the MySQL query.

@ﻼim: Thanks! Back at ya!

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

FlashCreations 20 Posting Whiz

:) 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!

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

FlashCreations 20 Posting Whiz

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
}
FlashCreations 20 Posting Whiz

Tizag has a great tutorial on getting started with PHP uploads. Read over it and post back if you have any questions.
Tip: Be sure to check the file type so users can't upload exe's, dll's or any non-image files.

ﻼim commented: really good at php. Ϋ +0
FlashCreations 20 Posting Whiz

hi there! Ϋ

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

:) thanks.

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.

FlashCreations 20 Posting Whiz

You could use ob_start() , 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 ob_get_contents() in a variable. Demo below:

index.php

//Start output buffering
ob_start();
//Get the contents of the dynamic page
require('dynamic.php?a=10');
//Get the contents of the page through the OB
$contents = ob_get_contents();

//To demonstrate it works
echo '$contents = ';
var_dump($contents);

dynamic.php

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

If you need to send POST variables to the dynamic page you could use cURL instead. A demo of this is below.

index.php

//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);
curl_close($c);

//To demonstrate it works
echo '$contents = ';
var_dump($contents);

dynamic.php

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

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.

FlashCreations 20 Posting Whiz

EDIT: To DaniWeb: Please update your posting system so if my token has expired when I post, I don't have to hit the back button and re-type everything.

Alright, take two. The gist of it is that there are two problems. The simpler of the two to fix is the problem regarding the URL. To access the var parameter you should use $matches[1] instead.
The second problem involving the style can be fixed in a similar manner as above, but also requires a Regex fix. Here is your revised code:

$this->avatar = $post->find('div[class=shell] td');
foreach($this->avatar as $avatar) {
	preg_match('/url\("([a-z0-9-_\.\/]*\/)?([a-z0-9-_\%\.]+)"\)/i', $avatar->style, $matches); // Thanks "FlashCreations"/"PhpMyCoder"!
	$this->avatar = $matches[2];
	echo $this->avatar . 'Hello world!';
}

Hope this fixes everything! :)
-PhpMyCoder

FlashCreations 20 Posting Whiz

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:

<?php
//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>
<html>
<head>
<title>PHP Popluate & Return Demo</title>
</head>
<body>

<form action="<?=$_SERVER['PHP_SELF']?>" method="get">

<?php $result = mysql_query("SELECT id, name FROM data") or die('Could not retrieve database information. Please try again later.'); ?>
<select name="id">
<?php while($data = mysql_fetch_array($result)): ?>
    <option value="<?=$data['id']?>"><?=$data['name']?></option>
<?php endwhile; ?>
</select>

<input type="Submit" name="action" value="View">
</form>


<?php if($_GET['action'] == 'View'): ?>

<?php if($result = mysql_query() && mysql_num_row($result) > 0): ?>
<table>
<thead>
    <td>ID</td>
    <td>Name</td>
    <td>Field1</td>
    <td>Field2</td>
    <!-- etc. -->
</thead>

<?php while($data = mysql_fetch_array($result)): ?>
<tr>
    <td><?= $data['id'] ?></td>
    <td><?= $data['name'] ?></td>
    <td><?= $data['field1'] ?></td>
    <td><?= $data['field2'] ?></td>
    <!-- etc. -->
</tr>
<?php endwhile; ?>

</table>
<?php else: ?>
<p>No results could be found for the given id</p>
<?php endif ?>

<?php endif; ?>
</body>
</html>
FlashCreations 20 Posting Whiz

Thanks man! If you need any help implementing it, shoot me a PM or post on the PHP forum.

Cheers,
PhpMyCoder :)

FlashCreations 20 Posting Whiz

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 MD5 Salts.

<?php
mysql_connect($host, $user, $pass);
mysql_select_db($db);

//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');
        exit();
    }
    //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');
    exit();
}
?>