NamePros.Com (http://www.namepros.com/)
-   CODE (http://www.namepros.com/code/)
-   -   Show certain tutorials. (http://www.namepros.com/code/181926-show-certain-tutorials.html)

Xyzer 03-29-2006 10:27 PM

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.

sacx13 03-30-2006 12:12 AM

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

Xyzer 03-30-2006 04:51 AM

My tutorials are all stored in a mysql database and i want it so when people submit them they can choose the catogoru.

asgsoft 03-30-2006 11:28 AM

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.

sacx13 03-30-2006 01:14 PM

Your site support adding categorys ? otherwise you need to change your database and all ...

Regards

Xyzer 03-30-2006 10:11 PM

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.

asgsoft 03-31-2006 12:58 AM

OK first what is ur pre-defined list

wackyjoe 03-31-2006 02:45 AM

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";
}
?>

sacx13 03-31-2006 02:58 AM

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

Xyzer 04-02-2006 11:43 AM

^^ what goes in the orange area?

asgsoft 04-02-2006 02:46 PM

that is a comment

Xyzer 04-03-2006 03:41 AM

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??

whyme953 04-03-2006 04:04 AM

i think what you want to do is

SELECT * FROM tutorials WHERE cat = 'photoshop'

then loop through the results.

Xyzer 04-03-2006 04:39 AM

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>

whyme953 04-03-2006 05:46 AM

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.

Xyzer 04-03-2006 06:12 AM

I have done this and its has worked the WHERE cat=photoshop.

Where can i put a statement if there is no tutorials??

Xyzer 04-03-2006 08:44 AM

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>

Xyzer 04-03-2006 10:30 PM

can anyone help me please?

whyme953 04-03-2006 11:26 PM

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.

Xyzer 04-04-2006 02:17 AM

Fixed thanks everyone.


All times are GMT -7. The time now is 01:53 PM.
Site Sponsors
Advertise your business at NamePros

Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0