User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,656 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,763 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1655 | Replies: 11
Reply
Join Date: Apr 2005
Location: Old Hampshire, Old England (LOL)
Posts: 11,937
Reputation: jbennet is a jewel in the rough jbennet is a jewel in the rough jbennet is a jewel in the rough jbennet is a jewel in the rough 
Rep Power: 30
Solved Threads: 264
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Microsoft Fanboy

Simple PHP Question

  #1  
Mar 12th, 2007
Ok here is my code:

 
<html>
 
<head>
<title> PHP Test Page </title>
</head>
 
<body>
 
<?php
 
echo date("H:i");
echo gmdate("M d Y");
 
$counter_file = "count.dat";
 
if(!($fp = fopen($counter_file, "r"))) die ("Cannot open $counter_file.");
$counter = (int) fread($fp, 20);
fclose($fp);
 
$counter++;
 
echo "You're visitor No. $counter.";
$fp = fopen($counter_file, "w");
fwrite($fp, $counter);
fclose($fp);
 
?>
</body>
 
</html>
 

this makes output saying:

 
18:32Mar 12 2007You're visitor No. 5. 
 

how can i make it so that they are on different lines, e.g

 
18:32
Mar 12 2007
You're visitor No. 5. 
 
Last edited by jbennet : Mar 12th, 2007 at 2:41 pm.
TRY MY SUGGESTIONS AT YOUR OWN RISK!
james.bennet1@ntlworld.com
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Posts: 4,663
Reputation: iamthwee is just really nice iamthwee is just really nice iamthwee is just really nice iamthwee is just really nice 
Rep Power: 16
Solved Threads: 297
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: Simple PHP Question

  #2  
Mar 12th, 2007
<br>

Possibly?
Member of: F-ugly code club

Join today don't delay!
Reply With Quote  
Join Date: Apr 2005
Location: Old Hampshire, Old England (LOL)
Posts: 11,937
Reputation: jbennet is a jewel in the rough jbennet is a jewel in the rough jbennet is a jewel in the rough jbennet is a jewel in the rough 
Rep Power: 30
Solved Threads: 264
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Microsoft Fanboy

Re: Simple PHP Question

  #3  
Mar 12th, 2007
ah yes

now heres a harder question, my site now looks like this

 
<html>
 
<head>
 
<title> PHP Test Page </title>
</head>
 
<body>
 
<h3><b><u>James Computers Order Form</u></b></h3>
 
<form action="process.php" method="post"> 
 
<select name="item"> 
<option>Computers</option>
<option>Monitors</option>
<option>PDA's</option>
</select>
 
Quantity: <input name="quantity" type="text" /> 
<input type="submit" />
 
</form>
 
<?php
 
echo date("H:i");
echo ", ";
echo gmdate("M d Y");
 
$counter_file = "count.dat";
if(!($fp = fopen($counter_file, "r"))) die ("<p><h4>Cannot open $counter_file.</h4></p>");
$counter = (int) fread($fp, 20);
fclose($fp);
 
$counter++;
 
echo "<p><h4>You are visitor number $counter</h4></p>";
 
$fp = fopen($counter_file, "w");
fwrite($fp, $counter);
fclose($fp);
 
?>
 
</body>
</html>
 

process.php looks like this:

 
<html>
<body>
 
<?php
$quantity = $_POST['quantity'];
$item = $_POST['item'];
echo "You ordered ". $quantity . " " . $item . ".<br />";
echo "Thank you for ordering from James Computers!";
?>
 
</body>
</html>
 


can anyone point me in the right direction of how to get this form to link with a mysql database
Last edited by jbennet : Mar 12th, 2007 at 3:38 pm.
TRY MY SUGGESTIONS AT YOUR OWN RISK!
james.bennet1@ntlworld.com
Reply With Quote  
Join Date: Aug 2005
Posts: 4,663
Reputation: iamthwee is just really nice iamthwee is just really nice iamthwee is just really nice iamthwee is just really nice 
Rep Power: 16
Solved Threads: 297
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: Simple PHP Question

  #4  
Mar 12th, 2007
As long as you supply the correct path to your database and the correct password.

Then select the correct database you should be good to go.
Member of: F-ugly code club

Join today don't delay!
Reply With Quote  
Join Date: Apr 2005
Location: Old Hampshire, Old England (LOL)
Posts: 11,937
Reputation: jbennet is a jewel in the rough jbennet is a jewel in the rough jbennet is a jewel in the rough jbennet is a jewel in the rough 
Rep Power: 30
Solved Threads: 264
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Microsoft Fanboy

Re: Simple PHP Question

  #5  
Mar 12th, 2007
ok i did it i used this site (veery good)

http://www.freewebmasterhelp.com/tutorials/phpmysql
Last edited by jbennet : Mar 12th, 2007 at 4:52 pm.
TRY MY SUGGESTIONS AT YOUR OWN RISK!
james.bennet1@ntlworld.com
Reply With Quote  
Join Date: Apr 2005
Location: Old Hampshire, Old England (LOL)
Posts: 11,937
Reputation: jbennet is a jewel in the rough jbennet is a jewel in the rough jbennet is a jewel in the rough jbennet is a jewel in the rough 
Rep Power: 30
Solved Threads: 264
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Microsoft Fanboy

Re: Simple PHP Question

  #6  
Mar 12th, 2007
ok one final problem:

 
<html>
 
<head>
<title>Test MYSQL PHP Page</title>
</head>
 
<body>
 
<h3><b><u>Test MYSQL PHP Page</u></b></h3>
 
<form action="insert_script.php" method="post">
 
<TABLE BORDER="1">
<tr>
<td>First Name: </td>
<td><input type="text" name="first"><br></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type="text" name="last"><br></td>
</tr>
<tr>
<td>Phone:</td>
<td><input type="text" name="phone"><br></td>
</tr>
<tr>
<td>Mobile:</td>
<td><input type="text" name="mobile"><br></td>
</tr>
<tr>
<td>E-mail: </td>
<td><input type="text" name="email"><br></td>
</tr>
 
<input type="Submit">
</form>
<?php
 
echo date("H:i");
echo ", ";
echo gmdate("M d Y");
 
$counter_file = "count.dat";
if(!($fp = fopen($counter_file, "r"))) die ("<p><h4>Cannot open $counter_file.</h4></p>");
$counter = (int) fread($fp, 20);
fclose($fp);
 
$counter++;
 
echo "<p><h4>You are visitor number $counter</h4></p>";
 
$fp = fopen($counter_file, "w");
fwrite($fp, $counter);
fclose($fp);
 
?>
 
<hr>
<h3><b><u>Database Tools</u></b></h3>
<a href="tbl_create_script.php">(Re)install database table</a> 
<p>
<a href="output_page.php">See output</a> 
<p>
<hr>
 
</body>
</html>
 

this is wierd. it puts the form on the bottom, button at the top and links in the middle?

i want the form, then the button then the links

screenshot enclosed

can anyone help me
Last edited by jbennet : Mar 12th, 2007 at 5:45 pm.
Attached Images
File Type: jpg php.JPG (21.8 KB, 6 views)
TRY MY SUGGESTIONS AT YOUR OWN RISK!
james.bennet1@ntlworld.com
Reply With Quote  
Join Date: Dec 2006
Posts: 34
Reputation: php_coder is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
php_coder php_coder is offline Offline
Light Poster

Re: Simple PHP Question

  #7  
Mar 13th, 2007
hii
give <br> after the time , date and count
i.e echo "<br>";

that should work
Reply With Quote  
Join Date: Apr 2005
Location: Old Hampshire, Old England (LOL)
Posts: 11,937
Reputation: jbennet is a jewel in the rough jbennet is a jewel in the rough jbennet is a jewel in the rough jbennet is a jewel in the rough 
Rep Power: 30
Solved Threads: 264
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Microsoft Fanboy

Re: Simple PHP Question

  #8  
Mar 13th, 2007
i ended up fixing it thanks
TRY MY SUGGESTIONS AT YOUR OWN RISK!
james.bennet1@ntlworld.com
Reply With Quote  
Join Date: Nov 2004
Location: tiny island in indian ocean
Posts: 138
Reputation: anastacia is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
anastacia's Avatar
anastacia anastacia is offline Offline
Junior Poster

Solution Re: Simple PHP Question

  #9  
Mar 18th, 2007
Originally Posted by jbennet View Post
Ok here is my code:

 
<html>
 
<head>
<title> PHP Test Page </title>
</head>
 
<body>
 
<?php
 
echo date("H:i");
echo gmdate("M d Y");
 
$counter_file = "count.dat";
 
if(!($fp = fopen($counter_file, "r"))) die ("Cannot open $counter_file.");
$counter = (int) fread($fp, 20);
fclose($fp);
 
$counter++;
 
echo "You're visitor No. $counter.";
$fp = fopen($counter_file, "w");
fwrite($fp, $counter);
fclose($fp);
 
?>
</body>
 
</html>
 

this makes output saying:

 
18:32Mar 12 2007You're visitor No. 5. 
 

how can i make it so that they are on different lines, e.g

 
18:32
Mar 12 2007
You're visitor No. 5. 
 




Just use a <br> tags within an echo. like this


echo' <br>';

after each output that you want to see
:lol: I am not one of those who wait for things to happen, :p but one of those who make things happen ;)
Reply With Quote  
Join Date: Apr 2005
Location: Old Hampshire, Old England (LOL)
Posts: 11,937
Reputation: jbennet is a jewel in the rough jbennet is a jewel in the rough jbennet is a jewel in the rough jbennet is a jewel in the rough 
Rep Power: 30
Solved Threads: 264
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Microsoft Fanboy

Re: Simple PHP Question

  #10  
Mar 18th, 2007
thanks man
TRY MY SUGGESTIONS AT YOUR OWN RISK!
james.bennet1@ntlworld.com
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 1:35 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC