Charas-Project

Off-Topic => Really Old Stuff => Archive => PHP => Topic started by: GaryCXJk on April 24, 2003, 06:14:18 PM

Title: PHP questions
Post by: GaryCXJk on April 24, 2003, 06:14:18 PM
I have some questions about PHP.

1) How do you create a table within the PHP script?
2) How was the php tag created (I want to create an own forum)?

Maybe I'll find some more questions.
Title:
Post by: Alex on April 24, 2003, 08:45:00 PM
1) Example (this will print a 10 cell row with values 1-10 into each):

print '';
for ($i=1;$i<=10;$i++) {
print '';
}
print '
'.$i.'
';

Same, but with 5 cells in 2 rows:

print '';
for ($i=1;$i<=10;$i++) {
print '';
if ($i==5) print '';
}
print '
'.$i.'
';


2) I don't understand what do you mean, here....
Maybe how the php tag is written? ( )
Title:
Post by: GaryCXJk on April 25, 2003, 09:01:07 AM
1) I actually meant how you could create a MySQL table. is it with the mysql_query() command?

2) I meant this tag:
 
print("This command, in this forum.")
echo($where,$you,$can,$see,$diffrent,$colors)
?>
Or something like that.
[PHP]...[ /PHP]
Title:
Post by: Alex on April 25, 2003, 09:54:27 AM
Uuuuuuuuuuuups... sorry.....
Table is table, i misunderstood! :D

Yes, mysql_query() is correct. After a mysql_connect(), of course ;)
About the sql syntax needed, give a look here:
http://www.mysql.com/doc/en/CREATE_TABLE.html

About php tag:
the "nw" class is the one with color definitions.


$bericht = preg_replace('_\[PHP\](.*?)\[/PHP\]_ise', "highlight(trim(stripslashes(' \\1 ')))", $bericht);

function highlight($code){
ob_start();
$code = str_replace(" <?", "<?", $code);
$code = str_replace("
", "", $code);
$code = str_replace('\\"', '\"', $code);
$code = str_replace("
", "", $code);
$code = str_replace("<", "<", $code);
$code = str_replace(">", ">", $code);
$code = str_replace(""", "\"", $code);
$code = str_replace("&", "&", $code);

highlight_string($code);
$code = ob_get_contents();
ob_end_clean();

$data_lines = explode('
',$code);
for ($i=0, $j=count($data_lines); $i < $j; $i++) {
$k = $i + 1;
$ret .= '
'.$k.'  '.$data_lines[$i]."
\n";
if (strlen($data_lines[$i]) > 450) {
$ret .= '
';
}
}

$string = "
PHP Code:
" . $ret . "
\n\n";
return $string;
}
Title:
Post by: madskaven1 on April 25, 2003, 10:53:58 PM
How do open the php file? im new to this stuff. :bend:
Title:
Post by: Alex on April 26, 2003, 10:37:46 AM
You need a web server.
Two possile scenarios: view them on your computer (offline) or via an external host which supports php.

ON YOUR COMPUTER
If you use windows, you have to install IIS (Internet Information Server) or PWS (Personal Web Server), if they're not already.
You will see if the installation is ok pointing you browser to http://127.0.0.1 (this is a special IP that identifies ALWAYS your machine, named LOCALHOST.

Then go to http://www.php.net/downloads.php and download the windows binary. If you're new to this kind of things, take the installer version.
After configuring php, what you need to do is:
- create a php file
- put it into some directory viewable by you web server
- view it via http
You cannot see php files simply double clicking on them: php is a server side language, so it has to be processed by the web server. This is why you can only see it pointing your browser, for example, to http://127.0.0.1/mydir/myfile.php
And finally, the code for a basic php test file (without the line numbers):

phpinfo();
?>

If all is ok, this will print out an info page about your php installation.

ON EXTERNAL HOST WITH PHP SUPPORT
This is more easy: just copy your php file into you web space and look at it as usual ( http://myprovider/mydir/myfile.php ).

Hope this helps, have fun! ;)
Title:
Post by: GaryCXJk on April 26, 2003, 11:54:53 AM
W00T!!! I FINALLY FOUND OUT HOW NUSPHERE WORKS!!! NOW I CAN TEST PHP SCRIPT OFF-LINE!!!
Title:
Post by: GaryCXJk on December 02, 2003, 11:42:50 AM
I'll kick this topic a bit.

You can download PHPDev on:

http://sourceforge.net/projects/phpdev5/