Yes, you could create each topic page manually, but that would be a nightmare to maintain if your site keeps growing.
If this is a personal site (like a blog), then you may want to look at a blogging platform like WordPress
Yes, you could create each topic page manually, but that would be a nightmare to maintain if your site keeps growing.
If this is a personal site (like a blog), then you may want to look at a blogging platform like WordPress
That's no problem! First of all, you don't put pages into a database, you put the pages content into various fields (columns) of the database table. So if you were to create a database for your site, you would have a table containing the topics:
| topic_id | topic_title | topic_hyperlink |
Maybe another table containing articles:
| article_id | topic_id | article_title | article_content | article_author | article_comments |
etc..
To answer your other question, yes you can set <div> tags to have a scroll bar using the CSS property 'overflow: auto;' - This will create a scrollbar - horizontal, vertical or both only if the content in the block requires it. For practical web development, this is probably the most useful approach to creating a scrollbar.
To be clear:
<div id="article" style="overflow:auto;"> content </div>
I would suggest staying away from Iframes as many browsers don't have good support for them. Instead I would recommend using html <div> tags to display each 'section'. Then each topic has a hyperlink that references content.php with an added topic variable.
Eg:
Topics:
<a href="content.php?topic=12">Global Warming</a>
<a href="content.php?topic=13">Child Labour</a>
Each link has a topic ID (?topic=12) - which links to each article in your database.
Then on content.php, get the value of the URL topic variable and dynamically fetch the corresponding topic content.
<?php
$topic = $_GET['topic'];
$get_topics = mysql_query("SELECT article FROM topics_table WHERE topic_id = '$topic'") or die(mysql_error());
$result_topic = mysql_fetch_assoc($get_topics);
?>
<div id = "article">
<?php echo $result_topic['article']; ?>
</div>
I assume you're using a database for your topics and articles?! This way, your site will be much more scalable :)
First of all, you won't be inserting an actual image into mysql. You will upload the image into a folder on your server, then MySQL will provide a link or path to that location, so the image can be displayed.
You'll need a column in your database called 'image' and set it to use a 'BLOB' data type. These tutorials should help you get started!
http://www.devarticles.com/c/a/MySQL/Blobbing-Data-With-PHP-and-MySQL/
http://www.anyexample.com/programming/php/php_mysql_example__image_gallery_(blob_storage).xml
<textarea value="<?php echo $_POST["article_summary"] ?>"></textarea>
Maybe something along the lines of this? Although I'm not sure that will work
edit: yeah, that definately doesn't work...
... text areas don't allow their content to be formatted differently. So I really don't know if it is possible to display a link like http://daniweb.com in a text area.
You could take the user input and create the link in a different html element though... It depends what you want exactly
Actually, mysql_fetch_array can return a result row as an associative array, a numeric array, or both! http://php.net/manual/en/function.mysql-fetch-array.php
Although I usually use mysql_fetch_assoc() as it's easier to determine the result resource.
Are you receiving any errors?
Instead of this:
$query = "SELECT * FROM lgmsevze_sunbrite.webtemps LIMIT 0, 2";
$sql = mysql_query($query);
Do this:
$query = mysql_query("SELECT * FROM lgmsevze_sunbrite.webtemps LIMIT 0,2") or die(mysql_error());
?>
<ul>
<?php
while ($item = mysql_fetch_array($query))
{
echo "<li><img src='localhost/sbd/".$item['image']."'></li>";
}
And tell us if you get an error
Obviously PHP as this is a PHP forum! :D
<?php
session_start();
$id = $_SESSION['recid'];
$school = $_SESSION['college'];
// Process the form if it is submitted
if ($_FILES['uploadedfile']['tmp_name'] != "") {
// Run error handling on the file
// Set Max file size limit to 120kb
$maxfilesize = 120000;
// Check file size, if too large exit
if($_FILES['uploadedfile']['size'] > $maxfilesize ) {
echo "Image too large.";
unlink($_FILES['uploadedfile']['tmp_name']);
exit();
// Check file extension to see if it is .jpg or .gif, if not exit
} else if (!preg_match("/\.(gif|jpg)$/i", $_FILES['uploadedfile']['name'] ) ) {
echo "Image not .gif or .jpg.";
unlink($_FILES['uploadedfile']['tmp_name']);
exit();
// If no errors on the file process it and upload to server
} else {
// Rename the pic
//Use the users numerical id to name the image file
// Set the upload folder
// Upload the file
if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], "memberFiles/".$newname)) {
echo "Image uploaded.";
exit();
} else {
echo "Upload error";
exit();
}
}
}
if(isset($_POST['remove']))
{
$File = "'memberFiles/'".$newname"";
unlink($File);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table>
<form action="test.php" method="post" enctype="multipart/form-data" name="form" id="form" >
<tr>
<td width="120"></td>
<td width="610" align="center"></td>
<td width="120" ></td>
</tr>
<tr>
<td></td>
<td><div align="center">
<input name="uploadedfile" type="file" />
<input type="submit" name="Submit" value="Upload Image" />
</div></td>
<td></td>
</tr>
<tr>
<td width="120"></td>
<td width="610"><div align="center">
<input name="remove" type="hidden" />
<input type="submit" name="remove" value="Remove Image" />
</div></td>
</tr>
</form>
</table>
</body>
</html>
Your remove button didn't have a unique name! I changed the name to 'remove'. …
You could use CSS display:none; or in HTML: <style="display:none;"> tag if you simply want to hide the image. I expect you're using a submit button to remove the image?
<?php
if(isset($_POST['remove']))
{
?>
<div id="image" style="display:none;">
//image here
</div>
<?php
}
else
{
?>
<div id="image">
//image here
</div>
<?php
}
?>
Otherwise, If you want to remove the image completely from the upload directory, you could maybe try using unlink()? Note:- I've not used this function before. Alternatively, you can delete a whole directory if necessary, by using rmdir()
<?php
if(isset($_POST['remove']))
{
$File = "'memberFiles/'. $newname";
unlink($File);
}
?>
You may also want to delete the image path from the database if you're using one. Also make sure that users have the correct permissions to delete files from the server!
Just found this on the php man page:
"careful with unlink...
"very unlikely" is not "impossible" : granted, it will happen.
1) "expected" : a typo and you'll get : unlink('/')
2) "very likely" : some of your files are writeable by anyone.
3) "possible" : you're backup drive is mounted and preserves the authorizations of the original files
4) "very unlikely" : that particular day, at that particular moment, the unlink function decided to work recursively"
If you want to use smarty for documentation, then you can use a tool called phpdocumentor.
Right, I have another idea. You could post the content of the variable across pages through the URL.
This should be the easiest solution. Add the content of the $artist variable to the URL so that it is sent across to the next/previous page. Forget about the session for now.
<?php
$next = " <a href=\"$self?page=$page&artist=$artist\">[Next]</a> "; //add artist var
?>
Then get the URL parameter using the $_GET method
<?php
if(isset($_POST['artist']))
{
$artist = $_POST['artist']; //get artist from input field
}
else
{
$artist = $_GET['artist']; //otherwise, get the artist from the URL parameter
}
?>
Well technically it's not the same page as you're passing a different parameter ($_GET) for each set of 15 results. The session should work. Test it using the code I posted
if (isset($artist))
{
//do the query
}
else
{
die("Artist Variable is Empty!");
}
If you still can't get it working, I will try and replicate it on my server
Ahhh... could it be the character encoding of your database?! Check this
Yes, the variable is being passed, but only once for the first page. You will need to store the user-supplied data in a session, rather than a variable for it to work across multiple pages! If you have not used sessions before, have a look at a tutorial like this one: http://php.about.com/od/advancedphp/ss/php_sessions.htm
The code I suggested in my first post gives you the majority of what you need:
<?php
session_start(); //this needs to be the first line on each page you need the variable for
$_SESSION['artist'] = $_POST['search']; //store the users input into a session variable
$artist = $_SESSION['artist']; //extract the user input from the session and store it back into a variable for each page.
//.....then issue the mysql query exactly as you have been doing
?>
Hope that helps. Give us a shout if you get stuck
hmm, that's a strange one! Surely if the variable is being passed, then there should be no reason why it won't work with the query? Your code looks good from what I can see.
Perhaps try testing with something along the lines of this:
if (isset($artist))
{
//do the query
}
else
{
die("Artist Variable is Empty!");
}
If you get 'artist variable is empty', at least you know it is a problem with the variable not being passed, and not with anything else.
Not exactly sure about this, but it could be because your search input field is saved as a variable. When you navigate to the next page, the variable is lost. You may be able to save the input text in a session, so it is available across all pages of the site!
$_SESSION['artist'] = $_POST['search'];
$artist = $_SESSION['artist'];
//query
You will also need a session_start(); at the top of your page if you go with this method.
So the windows-1251 didn't work?? Every russian site i've been to has this character encoding! Look here:
http://winrus.com/cpage_e.htm
"Most Russian-language Web pages (more than 90% for sure) are made nowadays in Windows-1251 encoding a.k.a. "Cyrillic(Windows)", just because the majority of authors work under MS Windows nowadays and 1251 is what Microsoft uses for Cyrillic, so built-in Windows Cyrillic fonts and keyboard tools are for Windows-1251 encoding."
<?php
if ($Valid == 0)
{
echo 'Incomplete Data, Redirecting...';
Redirect("QuoteAgeError.html");
}
/**
* JavaScript Redirect Function - Redirects the user should the result data be empty
* @param string $url the dynamic url to redirect to
*/
function Redirect($url)
{ ?>
<script type="text/javascript">
window.location = "<?php echo $url ?>"
</script>
<?php
}
?>
This will work
Can you give us some examples of the characters you're trying to display? Try:
<meta http-equiv="content-type" content="text/html; charset=windows-1251" />
You can have a look at this function I used a while ago to determine the file extension:
//--- DETERMINES IMAGE EXTENSION ---//
function getExtension($str) {
$i = strrpos($str,".");
if (!$i) {
return "";
}
$l = strlen($str)-$i;
$exten = substr($str,$i+1,$l);
return $exten;
}
$errors = 0;
$filename = stripslashes($_FILES['image']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension == "php") || ($extension == "phtml") || ($extension == "html") || ($extension == "js")) {
$errors = 1;
echo 'wrong extension';
}
if($errors >= 1) {
echo 'There was a problem';
die(1);
}
I can post the whole thing if you need it - it might make more sense that way. Just let me know :D
You'd do exactly the same as you would for a normal field. Create the necessary fields using
<input type="hidden" value="groupX" name="groupX">
Then on adminlogin.php get the value of the hidden field:
$hidden_field = $_POST['groupX'];
//Then insert into the database along with the text field as necessary
You will need to define the requirements for the system before that question can be answered. There is no set language for a particular type of project. It is down to you to recognise what is needed, what are the inputs and outputs, how will the users interact with the system? etc...
Hey. You'll need and if statement that takes the input value and checks to see what range it's in. Pretty simple really...
if ($input >= 0 and $input < 10)
{
echo "Input = 0-9";
}
elseif ($input >= 10 and $input < 20)
{
echo "Input = 10-20";
}
elseif ()
{
// etc
}
Create an array with all the months in it. Then if 5 is supplied as the month, just access the 5th element of the array.
You may want to put a dummy value in location 0 of the array so it makes it a bit easier to access the correct array key. E.g.
$months = array('dummy','Jan','Feb','Mar','April','May','June','July','Aug','Sept','Oct','Nov','Dec');
$oldm = 5;
$newm = $months[$oldm];
Sort out your indentation and curly braces - It makes things much easier to read and debug...
<?php
$totalg=($totala+$totalb+$totalc+$totald+$totale+$totalf)/6;
if($totalg <= 5.00 && $totalg >= 4.51)
{
$remark="Excellent";
}
elseif($totalg <= 4.50 && $totalg >= 3.51)
{
$remark="Very Satisfactory";
}
elseif($totag <= 3.50 && $totalg >= 2.51)
{
$remark="Satisfactory";
}
elseif($totalg <= 2.50 && $totalg >= 1.51)
{
$remark="Fair";}
elseif($totalg <= 1.50 && $totalg >= 1.00)
{
$remark="Needs Improvement";
}
echo $remark;
?>
You need to change 'else' to 'elseif' for each of the statements.
as hielo suggested, Quotation marks are required around the remark values
Also 'totalg' needs the '$' prefix! It is a variable.
I'm not sure, I have never tried passing an array as a URL parameter. However, you could save the array as a session and simply get the contents of it on the payment page. Or even a bunch of hidden fields and get the values through $_post rather than $_get?
$date = $_POST['date'];
$time = $_POST['time'];
$datetime = $date ." ". $time;
You can use sessions and/or cookies to accomplish this. E.g:
1. When each user logs in, start a session containing their username.
2. Simply check the content of the session variables to determine who is logged in
3. Close their session when the user has logged out.
There is tons of info on this. I can help, but I'm not prepared to the write the code for you.
I did try experimenting with ini_set('allow_url_include','On') but didn't have any success.
look into cURL. Note that this is horrible, security-wise.
strange... the code looks okay to me. Maybe start commenting out blocks of code to narrow down where the problem is occurring?
Yes of course there is! Although most companies have their own preference of CMS. Drupal, Joomla, Wordpress or their own custom one. So sound knowledge of a few of these, along with other web programming skills would make you desirable. I noticed that it is often the smaller > medium sized businesses that use CMS's.
Use Notepad++ It's by far the best Windows editor in my opinion. XAMPP for windows is also good (and free). It installs Apache, MySQL, PHP + PEAR, Perl, mod_php, mod_perl, mod_ssl, OpenSSL, phpMyAdmin, Webalizer, Mercury Mail Transport System for Win32 and NetWare Systems v3.32, Ming, JpGraph, FileZilla FTP Server, mcrypt, eAccelerator, SQLite, and WEB-DAV + mod_auth_mysql.
Wamp installs just Apache, MySQL, PHP and is also free
The easiest way to check if the path is correct is to right click where the broken image is displayed, then 'copy Image URL', then paste the shortcut which will tell you whether the path is output correctly.
If it looks correct, but still doesn't display the image, then try adding the full path to the location. E.g.
<img src=<?php echo "C://xampp/htdocs/images/". $thumbnail ?> >
<?php
$query = mysql_query("SELECT title FROM topics WHERE managerId='".$managerId."' AND egroup1='"."1"."' ORDER BY title ASC");
?>
<table>
<tr>
while($row1 = mysql_fetch_assoc($query))
{
$thumbnail = $row1['title'];
?>
<td><img src=<?php echo "images/". $thumbnail ?> /></td>
<?php
}
?>
</tr>
</table>
try this? and report back the results!
<img src="images/"<?php echo $thumbnail ?> />
first, go here https://www.paypal.com/cgi-bin/webscr?cmd=_flow&SESSION=-OFhTdPcLcZMjuhXSDNsvNW1Yr3GFqIfWonS7-Ap7-AHJT1q68Clu6UlAHy&dispatch=5885d80a13c0db1f8e263663d3faee8dc60d77e6184470d51976060a4ab6ee74 and create a button. This will generate the necessary html form for you.
Can you show us an example of what is contained within $thumbnail? Try removing the <br> and the '.=' may want to be changed to '='
You are allowed to use variables in path names. Are you using a windows or linux host?
You will need to get a PayPal button from the paypal website. From what I remember, there are two types or button, an encrypted one or an unencrypted one. I think you need an unencrypted one if you wish to plug in your own php variables into the paypal form.
It uses hidden fields to pass paypal the payee and product details. E.g:
<form
action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="paypal@mywebsite.com" />
<input type="hidden" name="return"
value="http://www.mywebsite.com/thankyou.html" />
<input type="hidden" name="item_name" value="Training Documents" />
<input type="hidden" name="amount" value="25.00" />
<input type="submit" value="Buy Now!" />
</form>
Here's a good link for some requisite research http://en.csharp-online.net/Encrypted_Website_Payments%E2%80%94PHP_Developers In addition, you may want to have a look at Instant Payment Notificaton (IPN) https://www.paypal.com/ipn
No problem. Best of luck with the new script! :)
Don't quote me on this, but I think it's because the array you're passing the foreach loop isn't initialised. I find the following to be interesting in the man page:
foreach works only on arrays, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variable.
<?php
if (isset($_POST['submit']))
{
$name = $_POST['name'];
$location = $_POST['location'];
$email = $_POST['email'];
$url = $_POST['url'];
$comments = $_POST['comments'];
$query = mysql_query("INSERT INTO guestbook (name,location,email,url,comments) VALUES ('$name', '$location', '$email', '$url', '$comments');") or die("Could not execute". mysql_error());
?>
<html>
<head></head>
<body>
<h2>Thanks!!</h2>
<h2><a href="view.php">View My Guest Book!!!</a></h2>
<?php
}
else
{
include("sign.php");
}
?>
</body>
</html>
Welcome asifsomy, well I'm not sure if I'm able to give you a detailed answer, but judging from my previous experience with Wordpress, I found it was quite limited and flat as a development platform. I've heard that alternatives such as Joomla and Drupal have far better project manipulation.
If you or your client are looking for a personal blogging site and you're not very 'code confident' then it's a good place to start. The main criticism I found was that I was limited to picking a pre-defined template for my site. Although this saved me time in designing and coding my own site, it also left me stuck in certain situations - unable to move that header or image to the location I wanted it. Again, implementing more advanced functionality such as a media player or a photo gallery may leave you constricted in terms of the site flexibility.
In summary the pros are:
- It's free
- It's easy to install
- Lots of pre-built add-ons, plug-ins and themes which can save you time
The cons:
- More suited to personal blogs than general websites.
- Below average Search engine optimisation
- Attracts spambots
- Very flat and limited to existing add-ons
- Frequent patching
I think you can have a database-driven site with wordpress, but you might want to look into this further. Here's a link which may help you decide for yourself:
Good. Now try adding this data to your database:
<?php
if (isset($_POST['submit']))
{
$name = $_POST['name'];
$location = $_POST['location'];
$email = $_POST['email'];
$url = $_POST['url'];
$comments = $_POST['comments'];
$query = mysql_query("INSERT INTO guestbook (name,location,email,url,comments) VALUES ('$name', '$location', '$email', '$url', '$comments');") or die("Could not execute". mysql_error());
}
?>
ok.... Put this in your create_entry.php file. Add some text to the input fields on the sign.php page and click submit. If you see what you typed after the create_entry page loads, then you know the values are there. Then we can concentrate on getting it into your database
<?php
if (isset($_POST['submit']))
{
$name = $_POST['name'];
$location = $_POST['location'];
$email = $_POST['email'];
$url = $_POST['url'];
$comments = $_POST['comments'];
echo $location ."<br>";
echo $email ."<br>";
echo $url ."<br>";
echo $comments ."<br>";
}
?>
<h2>Thanks!!</h2>
<h2><a href="view.php">View My Guest Book!!!</a></h2>
I just tested this.
<?php
include("dbconnect.php");
if ($submit == "Sign!")
{
$query = "insert into guestbook
(name,location,email,url,comments) values
('$name', '$location', '$email', '$url', '$comments')"
;
mysql_query($query) or
die (mysql_error());
?>
<h2>Thanks!!</h2>
<h2><a href="view.php">View My Guest Book!!!</a></h2>
<?php
}
else
{
include("sign.php");
}
?>
Okay, the main problem is within this file. You're telling it to insert variables that don't contain anything! You must get the input values using $_POST or $_GET.
E.g.
//check the user clicked the submit button
if(isset($_POST['submit']))
{
// get the user-supplied values from the input fields. Echo out these values to make sure they exist!
$name = $_POST['name'];
$location = $_POST['location'];
$email = $_POST['email'];
$url = $_POST['url'];
$comments = $_POST['comments'];
//then once you know the values exist, issue your mysql insert query.
$query = mysql_query("INSERT INTO guestbook (name,location,email,url,comments) VALUES ('$name','$location','$email','$url','$comments')") or die ("query failed". mysql_error());
}
Note, I haven't tested this. So read up on $_GET and $_POST, make sure the variables are holding the input data, then do the query. Hope that helps! Nonshatter
Please remember to wrap your code in [ code ] tags. What exactly do you mean by "everytime i run the sign.php form and i input entries into the form, i get this:" . Does the db connection file have <?php ?> tags??
<?php mysql_connect("localhost", "root","mobolaji") or die ("Could not connect to database"); mysql_select_db("guestbook") or die ("Could not select database"); ?>
*Edit:- If the file was wrapped in php tags you would get the error: "Could not select database" (as that's what you've told it to output with the die function). The error should not print the whole contents of the file.
You will need some sort of regular expression to find the matching word.
E.g:
$i=0;
while (there are results)
{
if(preg_match("/the search term/i", $results[$i], $yellow))
{
echo "<span id = "yellow">" $yellow[$i] . $results[$i] ."</span><br>";
}
}
Not exactly... but you can follow the logic x
Hi again,
Try this instead. I have used Javascript for the redirect as PHP can sometimes moan about headers:
if (!$html)
{
echo 'Incomplete Data, Redirecting...';
Redirect("error.html");
}
/**
* JavaScript Redirect Function - Redirects the user should the result data be empty
* @param string $url the dynamic url to redirect to
*/
function Redirect($url)
{ ?>
<script type="text/javascript">
window.location = "<?php echo $url ?>"
</script>
<?php
}