ComputerForum.com ComputerForum.com  
TigerDirect
 
Go Back   Computer Forum > Computer Software > Operating Systems

Reply
 
LinkBack Thread Tools Display Modes
Old 07-08-2005, 06:57 PM   #11 (permalink)
VIP Member
 
mgoldb2's Avatar
 
Join Date: Nov 2004
Age: 25
Posts: 1,259
Default

Quote:
Originally Posted by Cromewell
You could even eliminate stock of 0 at the SQL level (select * from stuff where stock > 0)
Personally this the way I would do it. Just make the query only return results you want.

change this

PHP Code:
// Create SQL statement
     
$query "SELECT * FROM cars"
to
PHP Code:
// Create SQL statement
     
$query "SELECT * FROM cars WHERE stock > 1"
Also you can have the user make query choises for example the following code

PHP Code:
</head>
 <body>
 
   <h1>make Query</h1>
   
   <form id="make_select" action="<?php $PHP_SELF?>" method="post">
   <p>
     Select vehicle make:
     <select name="make">
       <option value="Jeep">Jeep</option>
       <option value="Chevrolet">Chevrolet</option>
       <option value="Ford">Ford</option>
     </select>
 
     <input type="submit" />
   </p>
   </form>
 
   <?php
     
if( ! empty( $_POST["make"] ) )
     {
       echo 
'<table border="1">
             <tr>
               <th>ID</th>
               <th>Make</th>
               <th>Model</th>
               <th>Year</th>
               <th>Price</th>
             </tr>'
;
 
       require 
"dbinfo.php";
 
       
// Connect to MySQL DBMS
       
if (!($connection = @ mysql_connect(DB_HOSTNAMEDB_USERNAMEDB_PASSWORD)))
         
showerror();
 
       
// Use the cars database
       
if (!mysql_select_db(DB_DATABASENAME$connection))
         
showerror();
 
       
// Create SQL statement
       
$make $_POST["make"];
 
       
$query "SELECT * FROM cars WHERE make='$make'";
 
       
// Execute SQL statement
       
if (!($result = @ mysql_query ($query$connection)))
         
showerror();
 
       
// Display results
       
while ($row = @ mysql_fetch_array($result))
         echo 
"<tr>
                 <td>{$row["id"]}</td>
                 <td>{$row["make"]}</td>
                 <td>{$row["model"]}</td>
                 <td>{$row["year"]}</td>
                 <td>{$row["price"]}</td>
               </tr>"
;
 
       echo 
"</table>";
     }
   
?>
__________________
Acer A11912B 19"montior
Aspire x-superalien case
Asus k8t800 pro motherboard
athlon 64 fx-55
2GB(2 of 1GB) of Geil DDR ram
Geforce 6800 ultra
2 Seagate 200GB 7200RPM Model ST3200822A configure as RAID 0
1 DVDRW and 1 CDRW
3.5 drive
sound blaster audigey2 zs
logitech 2300 thx certified 2.1 speakers

Last edited by mgoldb2; 07-08-2005 at 07:03 PM.
mgoldb2 is offline   Reply With Quote


Old 07-08-2005, 07:08 PM   #12 (permalink)
P.I Dragon
 
dragon2309's Avatar
 
Join Date: May 2005
Location: KENT, UK
Age: 20
Posts: 8,420
Default

I like the sound of user customisable queries. I may try that later on when i have everything else set up. I know have a few more questions if you dont mind answering them for me??

1. Can i make a record in a query result a hyperlink, say my table is of necklaces and when Necklace301 gets displayed as a result from a query i want the user to be able to click on Necklace301 and go to the decription page of that necklace, can this be done or is it too complex.

2. Can an image be attatched to each record in the database, this is so that when a query returns all the results and they are in the table there is a picture of Necklace301 next to it and 302 next to 302 and so on, can this be done or is it again too complex.

Thanks in advance because i just know you will conme up with something, you have been extremely good so far and have helped immensely, thank you. dragon2309
__________________
Intel Core2Duo E6600 @ 3.1Ghz - (__CPU__)
eVGA 680i SLi - (__MOB__)
4Gb Corsair Dominator DDR2-800 (4x1024Mb) - (__RAM__)
250Gb Western Digital SATAII 7200rpm - (__HDD__)
nVidia BFG 8800GTS OC 320Mb - (__GFX__)
LG DVD+/-RW 18x DVD-RAM - (__OPT__)
Triple Boot - [XP Pro] + [Vista Ultimate] + [Ubuntu 7.10] - (__OS__)

[3DMARK'03 :: 25,587] --- [3DMARK'05 :: 13,989] --- [3DMARK'06 :: 8791] - (__BENCHMARKS__)


dragon2309.co.uk - a little slice of geek

dragon2309 is offline   Reply With Quote
Old 07-08-2005, 07:20 PM   #13 (permalink)
Moderator
 
Cromewell's Avatar
 
Join Date: Dec 2004
Location: Canada
Age: 25
Posts: 10,191
Default

1. I would store the URL of the necklace in the table (probably as a php page so that i can say displayitem.php?item=necklace or something like that) and then print the html link in the php script
PHP Code:
print "<a href=$row[url]> $row[name]</a>"
2. Same idea as 1 but store the img path (ie. images\necklace.jpg) and print img tags in the php script
__________________

You know what the chain of command is? It's the chain I go get and beat you with 'til ya understand who's in ruttin' command here.

I must plug a couple comics because they are good :D:
www.ctrlaltdel-online.com
www.userfriendly.org
Cromewell is offline   Reply With Quote
Old 07-08-2005, 07:25 PM   #14 (permalink)
P.I Dragon
 
dragon2309's Avatar
 
Join Date: May 2005
Location: KENT, UK
Age: 20
Posts: 8,420
Default

Im sorry, you lost me in all of that, where should the hyperlink go and should it be in the same table as the necklace or a different one, should i create a new field or what. Sorry for sounding dumb here.
__________________
Intel Core2Duo E6600 @ 3.1Ghz - (__CPU__)
eVGA 680i SLi - (__MOB__)
4Gb Corsair Dominator DDR2-800 (4x1024Mb) - (__RAM__)
250Gb Western Digital SATAII 7200rpm - (__HDD__)
nVidia BFG 8800GTS OC 320Mb - (__GFX__)
LG DVD+/-RW 18x DVD-RAM - (__OPT__)
Triple Boot - [XP Pro] + [Vista Ultimate] + [Ubuntu 7.10] - (__OS__)

[3DMARK'03 :: 25,587] --- [3DMARK'05 :: 13,989] --- [3DMARK'06 :: 8791] - (__BENCHMARKS__)


dragon2309.co.uk - a little slice of geek

dragon2309 is offline   Reply With Quote
Old 07-08-2005, 07:46 PM   #15 (permalink)
Moderator
 
Cromewell's Avatar
 
Join Date: Dec 2004
Location: Canada
Age: 25
Posts: 10,191
Default

ok say your products table looks like this:
products---
ProductName, Price, Stock, URL, image

I would have a php page called showproduct.php or showitem.php or whatever you like really (like the way this forum works). So you pull the link out of the product table and put it in the table you are using to organize the query results using the GET variable to indicate what product description it should go to
__________________

You know what the chain of command is? It's the chain I go get and beat you with 'til ya understand who's in ruttin' command here.

I must plug a couple comics because they are good :D:
www.ctrlaltdel-online.com
www.userfriendly.org
Cromewell is offline   Reply With Quote


Old 07-08-2005, 08:16 PM   #16 (permalink)
P.I Dragon
 
dragon2309's Avatar
 
Join Date: May 2005
Location: KENT, UK
Age: 20
Posts: 8,420
Default

Can you give an example of this, i think i understand but am not quite sure how to implement this new php page (showproduct.php). The URL's are now put into the products table, where do i go from there. can you give an exact piece of code to GET the page www.simplytrue.co.uk/necklaces_1.htm on this new showproduct.php page.
__________________
Intel Core2Duo E6600 @ 3.1Ghz - (__CPU__)
eVGA 680i SLi - (__MOB__)
4Gb Corsair Dominator DDR2-800 (4x1024Mb) - (__RAM__)
250Gb Western Digital SATAII 7200rpm - (__HDD__)
nVidia BFG 8800GTS OC 320Mb - (__GFX__)
LG DVD+/-RW 18x DVD-RAM - (__OPT__)
Triple Boot - [XP Pro] + [Vista Ultimate] + [Ubuntu 7.10] - (__OS__)

[3DMARK'03 :: 25,587] --- [3DMARK'05 :: 13,989] --- [3DMARK'06 :: 8791] - (__BENCHMARKS__)


dragon2309.co.uk - a little slice of geek

dragon2309 is offline   Reply With Quote
Old 07-08-2005, 09:20 PM   #17 (permalink)
Moderator
 
Cromewell's Avatar
 
Join Date: Dec 2004
Location: Canada
Age: 25
Posts: 10,191
Default

You don't have to use a showproduct page but it allows you to add/remove things very easily because all you have to do is add/remove a row from the table.
basically showproduct.php would recreate the page you've got but it wouldn't fill in any of the changing areas (the picture, description, price, etc)
You could even use that page as a template (change the image and description and stuff to {IMG} or something easy to find and replace) and use substr to replace the variable stuff with what you need.

I think I have my PHP forum project at home, it uses a show page I'll send it to you if you like.
__________________

You know what the chain of command is? It's the chain I go get and beat you with 'til ya understand who's in ruttin' command here.

I must plug a couple comics because they are good :D:
www.ctrlaltdel-online.com
www.userfriendly.org
Cromewell is offline   Reply With Quote
Old 07-09-2005, 01:00 AM   #18 (permalink)
P.I Dragon
 
dragon2309's Avatar
 
Join Date: May 2005
Location: KENT, UK
Age: 20
Posts: 8,420
Default

That would be great if you could send it to me, my gmail account is dragon2309@gmail.com Thanks. I think a bit of hands on evaluating is needed, just tosee what its supposed to do and what it looks like.
__________________
Intel Core2Duo E6600 @ 3.1Ghz - (__CPU__)
eVGA 680i SLi - (__MOB__)
4Gb Corsair Dominator DDR2-800 (4x1024Mb) - (__RAM__)
250Gb Western Digital SATAII 7200rpm - (__HDD__)
nVidia BFG 8800GTS OC 320Mb - (__GFX__)
LG DVD+/-RW 18x DVD-RAM - (__OPT__)
Triple Boot - [XP Pro] + [Vista Ultimate] + [Ubuntu 7.10] - (__OS__)

[3DMARK'03 :: 25,587] --- [3DMARK'05 :: 13,989] --- [3DMARK'06 :: 8791] - (__BENCHMARKS__)


dragon2309.co.uk - a little slice of geek

dragon2309 is offline   Reply With Quote
Old 07-09-2005, 01:53 PM   #19 (permalink)
P.I Dragon
 
dragon2309's Avatar
 
Join Date: May 2005
Location: KENT, UK
Age: 20
Posts: 8,420
Default

I have entered the html link into the mysql table it is now being displayed in the query results. The only problem is that it is in just plain text, it is not a hyperlink and there is no way to click on it, unless the user physically copies and pastes it into their browser address bar, which defeats the object of it in the first place. Any ideas??

Is there a certain field type it has to be set to in the SQL level of things, at the moment it is on varchar which is default. I had a quick look through and didnt find any hyperlink stuff.

The same with any links to image files, i think i am doing it wrong, can you help.

*UPDATE* This is what it comes out like.....
__________________
Intel Core2Duo E6600 @ 3.1Ghz - (__CPU__)
eVGA 680i SLi - (__MOB__)
4Gb Corsair Dominator DDR2-800 (4x1024Mb) - (__RAM__)
250Gb Western Digital SATAII 7200rpm - (__HDD__)
nVidia BFG 8800GTS OC 320Mb - (__GFX__)
LG DVD+/-RW 18x DVD-RAM - (__OPT__)
Triple Boot - [XP Pro] + [Vista Ultimate] + [Ubuntu 7.10] - (__OS__)

[3DMARK'03 :: 25,587] --- [3DMARK'05 :: 13,989] --- [3DMARK'06 :: 8791] - (__BENCHMARKS__)


dragon2309.co.uk - a little slice of geek


Last edited by dragon2309; 12-21-2005 at 05:45 PM.
dragon2309 is offline   Reply With Quote
Old 07-09-2005, 08:27 PM   #20 (permalink)
Moderator
 
Cromewell's Avatar
 
Join Date: Dec 2004
Location: Canada
Age: 25
Posts: 10,191
Default

You need to do more than just print the link text, you have to put it in html tags.
__________________

You know what the chain of command is? It's the chain I go get and beat you with 'til ya understand who's in ruttin' command here.

I must plug a couple comics because they are good :D:
www.ctrlaltdel-online.com
www.userfriendly.org
Cromewell is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:18 AM.


Powered by: vBulletin Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.
Copyright © 2002-2008 Computer Forum and Web Design Forum