callisto11 Posted February 2, 2008 Share Posted February 2, 2008 Hi everyone, below is a copy of my script, that uploads pictures of sports from my database onto my website.this based on the catergory, i want to be able to modify this script to also upload pictures from all the different catergories that i have created on their individual pages, without me having to write same code over again and over again for each catergory. At the moment theres six different catergory in my table called general cartoons. (I know i might not be making sense, but its hard to explain something without the person seeing it,if you understand what I mean, Im in desperate need of sorting this out!) Im very new to using php and my sql and I've search everywhere on the web to help me with this problem. ??? Thank you <?php session_start(); require "connect.php"; $query = "select * from general_cartoon where subject_type='sport'"; $result = @mysql_query($query, $connection) or die ( "Unable to perform query.<br/>$query<br/>".mysql_error()); //require "shoppingcart.php"; ?> <html> <body> <center> <h1><img src="logo.jpg" align=center width="600" height="200"></h1> </center> <html> <body> <table border=0 width=900> <tr> <td valign=top width=200> <p><a href="homepage.php">ARTIST</a></p> <p><a href="gallery.php">GALLERY</a></p> <p><a href="">CONTACT</a></p> <p><a href="customerlogin.php">SIGN IN/ SIGN-UP</a></p> <p><a href="">FORMAT/PRICE</a></p> <p><a href="shoppingcart.php">VIEW SHOPPING CART</a></p> </td> <td valign=top width=700><p> <ol type="A"> <font face="scans-serif" color="Purple" size="+5" align="right" >SPORT </p> </ol> </td> </tr> </table> </body> </html> <html> <body> <center> <table border="6"> <tr> <th >TITLE</th> <th >CARTOON</th> <th> </th> </tr> <?php while($row= mysql_fetch_array($result)) { echo "<tr>"; echo "<td>".$row['title']."</td>"; echo "<td><img src=\"pics/".$row['location_of_cartoon']."\"></td>" ; ?> <td><a href="addtoshoppingcart.php?cartoon_id=<?php echo $row['cartoon_id']; ?>&title=<?php echo $row['title']; ?>"> [ADD] </a></td></tr> <?php } ?> </table> <center> Quote Link to comment https://forums.phpfreaks.com/topic/89091-how-to-create-multiple-pages-from-one-php-script/ Share on other sites More sharing options...
monkeytooth Posted February 2, 2008 Share Posted February 2, 2008 Not to sure If I understand correctly.. but ill give it a go.. Rather then 6 scripts of the same nature.. you could introduce a variable to the script that would define the category.. so pending on the variable the script would upload it to the appropriate section. your code: $query = "select * from general_cartoon where subject_type='sport'"; $result = @mysql_query($query, $connection) or die ( "Unable to perform query. $query Alternative: $query = "select * from general_cartoon where subject_type='$category_type'"; $result = @mysql_query($query, $connection) or die ( "Unable to perform query. $query There is still modifications you will have to make to the over all page/script. But its possible to do what you want. You can define the "$category_type" through a var passed in a URL, or via a form, or multiple other ways.. but mostly depends on how the rest of your site works. example of link would be: www.blah.com/page.php?cat=sport but again depending on the rest of the structure is how you would want to lay that out.. Couldn't really say as I don't know exactly how the site works thats in question.. Quote Link to comment https://forums.phpfreaks.com/topic/89091-how-to-create-multiple-pages-from-one-php-script/#findComment-456314 Share on other sites More sharing options...
callisto11 Posted February 2, 2008 Author Share Posted February 2, 2008 THE Field is not actually called catergory_type, its called subject_type. I've tried changing it and its not working. I don't know what im doing wrong or is the whole script that needs modifying. So what Im saying is suject type is alway different. In my database the pictures are saved based on their subject type. So On my website I want all subject types pictures to displayed on different pages using one script. (Im soooooo confused on how to do it!) Quote Link to comment https://forums.phpfreaks.com/topic/89091-how-to-create-multiple-pages-from-one-php-script/#findComment-456332 Share on other sites More sharing options...
monkeytooth Posted February 2, 2008 Share Posted February 2, 2008 $category_type i was just using for sample sake If I am understanding you right then yes, as previously state the whole script may need some alterations in order to work accordingly with what you want. Unfortunately what you want done is going to need a bit of coding on top of whats there to work the way you want it to, theres no escape from that. Ultimately (not my style) but a page for every subject containing the same code but for that subject.. Or.. altering the coder over all and possibly a few elements else where pending on your layout to make one page work dynamically for each subject. Quote Link to comment https://forums.phpfreaks.com/topic/89091-how-to-create-multiple-pages-from-one-php-script/#findComment-456335 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.