 |
Results from the most recent live auction are here.
20 members in the live chat room. Join Chat!
| |
03-29-2006, 10:27 PM
|
· #1 | | Steven Name: Steven Gibbons Location: United Kindom Join Date: Aug 2005
Posts: 1,506
NP$: 40.00 ( Donate)
| Show certain tutorials. Hi,
I have a tutorial site here at www.x6core.com, and people submit tutorials, how would i make it so when the submit the choose a catorogry for the tutorial? I think on say the photoshop page the code could be something like this, but im not sure. Can someone help please? P.S All the records are in a mysql database. Code:
if $categories == photoshop{
showrecord}
Im not sure how to show all records that meet criteria. |
| |
03-30-2006, 12:12 AM
|
· #2 | | NamePros Regular Join Date: Mar 2006
Posts: 394
NP$: 286.68 ( Donate)
| We need to know more ... When the tutorials are posted you you can decide for a category ? If yes then you can select them. If not the single posibility is to look in title after "category" like "photoshop".
Your tutorials are in sql database or are simple text files on harddrive ?
Regards
Adrian |
| |
03-30-2006, 04:51 AM
|
· #3 | | Steven Name: Steven Gibbons Location: United Kindom Join Date: Aug 2005
Posts: 1,506
NP$: 40.00 ( Donate)
| My tutorials are all stored in a mysql database and i want it so when people submit them they can choose the catogoru. |
| |
03-30-2006, 11:28 AM
|
· #4 | | NamePros Regular Location: At Home Join Date: Sep 2005
Posts: 806
NP$: 981.10 ( Donate)
| do you have a pre-defined list
if you sign up to http://aysha.hostmatrix.org/ and see the form for submitting a tutorial should show you a good example. |
| |
03-30-2006, 01:14 PM
|
· #5 | | NamePros Regular Join Date: Mar 2006
Posts: 394
NP$: 286.68 ( Donate)
| Your site support adding categorys ? otherwise you need to change your database and all ...
Regards |
| |
03-30-2006, 10:11 PM
|
· #6 | | Steven Name: Steven Gibbons Location: United Kindom Join Date: Aug 2005
Posts: 1,506
NP$: 40.00 ( Donate)
| I know i will change the database and everything but i want the predifined list then a page that shows all the ones in which the catogory is photoshop. |
| |
03-31-2006, 12:58 AM
|
· #7 | | NamePros Regular Location: At Home Join Date: Sep 2005
Posts: 806
NP$: 981.10 ( Donate)
| OK first what is ur pre-defined list |
| |
03-31-2006, 02:45 AM
|
· #8 | | NamePros Regular Join Date: Dec 2005
Posts: 206
NP$: 270.00 ( Donate)
| umm not quite getting wht your saying?
try: PHP Code: <a href="/tutorials.php?cat=photoshop">Photoshop</a>
PHP Code: <?php
$cat = $_GET['cat'];
if ($cat == "photoshop") {
//whtever u can here
}
else
{
echo"Invalid Category";
}
?> |
| |
03-31-2006, 02:58 AM
|
· #9 | | NamePros Regular Join Date: Mar 2006
Posts: 394
NP$: 286.68 ( Donate)
| Is more easy in this way ... PHP Code: <?php
function get_articles_cat($cat)
{
// sql stuff searching for articles from categories $cat
}
$cat = $_GET['cat'];
if ($cat != "") get_articles_cat($cat);
?>
if you trto doit with if's you will need to add a if for each category added
Regards |
| |
04-02-2006, 11:43 AM
|
· #10 | | Steven Name: Steven Gibbons Location: United Kindom Join Date: Aug 2005
Posts: 1,506
NP$: 40.00 ( Donate)
| ^^ what goes in the orange area? |
| |
04-02-2006, 02:46 PM
|
· #11 | | NamePros Regular Location: At Home Join Date: Sep 2005
Posts: 806
NP$: 981.10 ( Donate)
| that is a comment |
| |
04-03-2006, 03:41 AM
|
· #12 | | Steven Name: Steven Gibbons Location: United Kindom Join Date: Aug 2005
Posts: 1,506
NP$: 40.00 ( Donate)
| right, i like the way this one is made and i want to use it: Code: <?php
$cat = $_GET['cat'];
if ($cat == "photoshop") {
//whtever u can here
}
else
{
echo"Invalid Category";
}
?>
I dont know how to intergrate it with this: Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<?php
$connect = mysql_connect("localhost", "dbun", "dbpw");
mysql_select_db("dbname", $connect);
$select = mysql_query("SELECT * FROM `tutorials`", $connect);
while($row = mysql_fetch_array($select, MYSQL_ASSOC)) {
$id = $row['id'];
$name = $row['name'];
$email = $row['email'];
$url = $row['url'];
$url2 = $row['url2'];
$WebsiteName = $row['WebsiteName'];
$TutorialName = $row['TutorialName'];
$description = $row['description'];
echo "
<p>
<strong>Tutorial Name:</strong> <a href=\"$url2\">$TutorialName</a><br />\n
<strong>Submitted By:</strong> <a href=\"$url\">$WebsiteName</a><br />\n
<strong>Description:</strong> $description
</p>
";
}
?>
I think it should be: Code:
<?php
$connect = mysql_connect("localhost", "bdun", "dbpw");
mysql_select_db("dbname", $connect);
$select = mysql_query("SELECT * FROM `tutorials`", $connect);
while($row = mysql_fetch_array($select, MYSQL_ASSOC)) {
$id = $row['id'];
$name = $row['name'];
$email = $row['email'];
$url = $row['url'];
$url2 = $row['url2'];
$WebsiteName = $row['WebsiteName'];
$TutorialName = $row['TutorialName'];
$description = $row['description'];
$cat = $row['cat'];
}
if ($cat == "photoshop") {
//echo statement??
echo "
<p>
<strong>Tutorial Name:</strong> <a href=\"$url2\">$TutorialName</a><br />\n
<strong>Submitted By:</strong> <a href=\"$url\">$WebsiteName</a><br />\n
<strong>Description:</strong> $description
</p>";
}
else {
echo "There are no tutorial in this category";
{
?>
Is this correct?? |
| |
04-03-2006, 04:04 AM
|
· #13 | | NamePros Member Join Date: Jun 2004
Posts: 92
NP$: 183.00 ( Donate)
| i think what you want to do is
SELECT * FROM tutorials WHERE cat = 'photoshop'
then loop through the results. |
| |
04-03-2006, 04:39 AM
|
· #14 | | Steven Name: Steven Gibbons Location: United Kindom Join Date: Aug 2005
Posts: 1,506
NP$: 40.00 ( Donate)
| Thanks, ive done a copy with my code and get this error: Code: Parse error: syntax error, unexpected $end in /home/gibbons/public_html/photoshop.php on line 37
In Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<?php
$connect = mysql_connect("localhost", "dbun", "dbpw");
mysql_select_db("dbname", $connect);
$select = mysql_query("SELECT * FROM `tutorials`", $connect);
while($row = mysql_fetch_array($select, MYSQL_ASSOC)) {
$id = $row['id'];
$name = $row['name'];
$email = $row['email'];
$category = $row['category'];
$url = $row['url'];
$url2 = $row['url2'];
$WebsiteName = $row['WebsiteName'];
$TutorialName = $row['TutorialName'];
$description = $row['description'];
if ($category == "Photoshop"){
echo " <p>
<strong>Tutorial Name:</strong> <a href=\"$url2\">$TutorialName</a><br />\n
<strong>Submitted By:</strong> <a href=\"$url\">$WebsiteName</a><br />\n
<strong>Description:</strong> $description
</p>";
}
else {
echo "Sorry, There are currently no tutorials in this category.";
}
?>
</body>
//LINE 37 BELOW
</html> |
| |
04-03-2006, 05:46 AM
|
· #15 | | NamePros Member Join Date: Jun 2004
Posts: 92
NP$: 183.00 ( Donate)
| you're missing the closing } for the while($row = mysql_fetch_array... statement.
generally when you get an error like that on the last line that's what it is. |
| |
04-03-2006, 06:12 AM
|
· #16 | | Steven Name: Steven Gibbons Location: United Kindom Join Date: Aug 2005
Posts: 1,506
NP$: 40.00 ( Donate)
| I have done this and its has worked the WHERE cat=photoshop.
Where can i put a statement if there is no tutorials??
Last edited by webmonkey : 04-03-2006 at 06:41 AM.
|
| |
04-03-2006, 08:44 AM
|
· #17 | | Steven Name: Steven Gibbons Location: United Kindom Join Date: Aug 2005
Posts: 1,506
NP$: 40.00 ( Donate)
| also now what has happened is that it wont display the site and tutorial name, check here: http://www.x6core.com/?id=photoshoptutorials But all i have changed is the where cat = photoshop, if you want to see my code its here: Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<?php
//Connect goes here, but deleted user and pw.
$select = mysql_query("SELECT * FROM `tutorials` WHERE category = 'photoshop'", $connect);
while($row = mysql_fetch_array($select, MYSQL_ASSOC)) {
$category = $row['category'];
$id = $row['id'];
$name = $row['name'];
$email = $row['email'];
$url = $row['url'];
$url2 = $row['url2'];
$WebsiteName = $row['WebsiteName'];
$TutorialName = $row['TutorialName'];
$description = $row['description'];
echo "
<p>
<strong>Tutorial Name:</strong> <a href=\"$url2\">$TutorialName</a><br />\n
<strong>Submitted By:</strong> <a href=\"$url\">$WebsiteName</a><br />\n
<strong>Description:</strong> $description
</p>
";
}
?>
</body>
</html> |
| |
04-03-2006, 10:30 PM
|
· #18 | | Steven Name: Steven Gibbons Location: United Kindom Join Date: Aug 2005
Posts: 1,506
NP$: 40.00 ( Donate)
| can anyone help me please? |
| |
04-03-2006, 11:26 PM
|
· #19 | | NamePros Member Join Date: Jun 2004
Posts: 92
NP$: 183.00 ( Donate)
| after you run the mySQL query add this: PHP Code: if (mysql_num_rows($select) >0) {//there are tutorials in this cat.
//print out your stuff
} else {//nothing in this cat.
echo 'Sorry, no tutorials in this category'; //replace with message of your choice.
}
i'm not sure if this is what you're looking for or not. hope it helps. |
| |
04-04-2006, 02:17 AM
|
· #20 | | Steven Name: Steven Gibbons Location: United Kindom Join Date: Aug 2005
Posts: 1,506
NP$: 40.00 ( Donate)
| Fixed thanks everyone. |
| |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | |