Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

Show certain tutorials.

SpaceshipSpaceship
SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Watch
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.
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
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
 
0
Close
My tutorials are all stored in a mysql database and i want it so when people submit them they can choose the catogoru.
 
0
Close
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.
 
0
Close
Your site support adding categorys ? otherwise you need to change your database and all ...

Regards
 
0
Close
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.
 
0
Close
OK first what is ur pre-defined list
 
0
Close
umm not quite getting wht your saying?

try:

PHP:
<a href="/tutorials.php?cat=photoshop">Photoshop</a>

PHP:
<?php
$cat = $_GET['cat'];

if ($cat == "photoshop") {
//whtever u can here
}
else
{
echo"Invalid Category";
}
?>
 
1
Close
Is more easy in this way ...

PHP:
<?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
 
1
Close
^^ what goes in the orange area?
 
0
Close
that is a comment
 
1
Close
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??
 
0
Close
i think what you want to do is

SELECT * FROM tutorials WHERE cat = 'photoshop'

then loop through the results.
 
1
Close
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>
 
0
Close
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.
 
0
Close
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:
0
Close
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>
 
0
Close
can anyone help me please?
 
0
Close
after you run the mySQL query add this:
PHP:
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.
 
0
Close
Fixed thanks everyone.
 
0
Close
Appraise.net

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Member card: see how many threads a member started
The member card now shows a Threads number, right after Posts. The member card is the box that opens when you point at a name. Profile...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back