Jump to content

Calling an array "<Price" from the URL


colleyboy

Recommended Posts

Hi people,

 

Having a small problem.

 

I have managed to call arrays for the types and colours but now I want to call price.

 

I tried "carpetprice.php?price=<30.00" but it arrays nothing.

 

Wondering what I am doing wrong... hmm. 

 

I basically want to array prices below a certain price when typed into the url...

 

I.E: carpetprice.php?price=<30.00 (Show all products with price below £30.00)

carpetprice.php?price=<20.00 (Show all products with price below £20.00)

 

Can't seem to work it out...

help is needed i think :).

 

Many Thanks..

 

Heres the page coding below:

 

<HTML>

<HEAD>

<?php

include ('dbconnect.php');

?>

<TITLE>Supreme Carpets - High Quality Carpets at affordable prices - Grays High Street, Essex</TITLE>

</HEAD>


<BODY leftmargin="0" rightmargin="0" bottommargin="0" topmargin="3" LINK="BLACK" ALINK="BLACK" VLINK="BLACK">



<CENTER>

<TABLE CELLPADDING="0" CELLSPACING="0" WIDTH="100%" BORDER="0"><TR><TD><CENTER><A HREF="index.php"><IMG SRC="images/tabs/carpet1.png" border="0"></A><A HREF="laminate.php"><IMG SRC="images/tabs/laminate1.png" border="0"></A><A HREF="vinyl.php"><IMG SRC="images/tabs/vinyl1.png" border="0"></A></A><A HREF="bookacall.php"><IMG SRC="images/tabs/bookacall1.png" border="0"></A><A HREF="contactus.php"><IMG SRC="images/tabs/contactus1.png" border="0"></A></CENTER></TD></TR></TABLE><TABLE CELLPADDING="0" CELLSPACING="0" WIDTH="100%" HEIGHT="100%" BGCOLOR="#be9051"><TR><TD valign="top">
</CENTER>

<!-- MAIN -->

<CENTER><FONT SIZE="2" FACE="VERDANA"><B>Looking for blinds? Click here!</B></CENTER>


<TABLE CELLPADDING="0" CELLSPACING="0" WIDTH="100%">

<TR>

<TD><MARQUEE><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"><IMG SRC="images/main/banner.png"></MARQUEE></TD>

</TR>

</TABLE>


<!-- START OF LOWER PART OF WEBSITE -->

<TABLE CELLPADDING="0" CELLSPACING="0" WIDTH="100%" BORDER="0">

<TR>


<TD WIDTH="10" valign="top"> </TD>

<TD WIDTH="252" HEIGHT="385" valign="top">

<!-- SEARCH BOX -->

<TABLE CELLPADDING="0" CELLSPACING="0" WIDTH="100%">

<TR>

<TD WIDTH="23"><IMG SRC="images/main/search/topleft.png"></TD>

<TD BACKGROUND="images/main/search/top.png"> </TD>

<TD WIDTH="23"><IMG SRC="images/main/search/topright.png"></TD>

</TR>


<TR>

<TD BACKGROUND="images/main/search/left.png" WIDTH="23"> </TD>

<TD BACKGROUND="images/main/search/bg.png">

<!-- SEARCH BOX TEXT -->

<FONT FACE="VERDANA" SIZE="2">

<CENTER><IMG SRC="images/main/search/searchheader.png"></CENTER>
<B>By Colour</B><BR>


<A HREF="carpetcolour.php?colour=cream"><IMG SRC="images/main/search/colours/creme.png" title="Cream, Ivory" border="0"></A> <A HREF="carpetcolour.php?colour=beige"><IMG SRC="images/main/search/colours/biege.png" title="Beige" border="0"></A> <A HREF="carpetcolour.php?colour=brown"><IMG SRC="images/main/search/colours/brown.png" title="Brown" border="0"></A><BR>

<A HREF="carpetcolour.php?colour=lilac"><IMG SRC="images/main/search/colours/lilac.png" title="Lilac, Purple" border="0"></A> <A HREF="carpetcolour.php?colour=blue"><IMG SRC="images/main/search/colours/blue.png" title="Blue" border="0"></A> <A HREF="carpetcolour.php?colour=black"><IMG SRC="images/main/search/colours/black.png" title="Grey, Black, Silver" border="0"></A><BR>

<A HREF="carpetcolour.php?colour=green"><IMG SRC="images/main/search/colours/green.png" title="Green" border="0"></A> <A HREF="carpetcolour.php?colour=yellow"><IMG SRC="images/main/search/colours/yellow.png" title="Yellow, Gold" border="0"></A> <A HREF="carpetcolour.php?colour=red"><IMG SRC="images/main/search/colours/red.png" title="Orange, Red, Terracotta, Burgundy, Peach, Pink" border="0"></A><BR>
<FONT SIZE="1"><CENTER><U>See all</U></CENTER></FONT>
<BR>


<B>By Price per square metre</B><BR><BR>

- £0.00 - £5.00 psm<BR>
- £5.00 - £10.00 psm<BR>
- £10.00 - £15.00 psm<BR>
- £15.00 - £20.00 psm<BR>
- £20.00 - £25.00 psm<BR>
- £25.00 - £30.00 psm<BR>
- £30.00 - £35.00 psm<BR>
- £35.00 - £40.00 psm<BR>
- £40.00 - £45.00 psm<BR>
- £45.00 - £50.00 psm<BR>
- £50.00+ psm<BR>


<!-- END OF SEARCH BOX TEXT -->

</TD>

<TD BACKGROUND="images/main/search/right.png" WIDTH="23"> </TD>

</TR>


<TR>

<TD WIDTH="23"><IMG SRC="images/main/search/bottomleft.png"></TD>

<TD BACKGROUND="images/main/search/bottom.png"> </TD>

<TD WIDTH="23"><IMG SRC="images/main/search/bottomright.png"></TD>

</TR>


</TABLE>





<!-- END OF SEARCH BOX -->

</TD>

<TD WIDTH="10" valign="top"> </TD>

<TD valign="top">

<!-- START OF RIGHT HAND MAIN SIDE -->



<!-- CENTRAL RIGHT -->

<?php
// Make a MySQL Connection

$what_price=$_GET['price'];
$query="SELECT * FROM carpets WHERE price = '$what_type'";

$result = mysql_query($query) or die(mysql_error());


while($row = mysql_fetch_array($result)){

echo "<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH=100% />";
echo "<TR />";
echo "<TD WIDTH=23 /><IMG SRC=images/main/search/topleft.png /></TD />";
echo "<TD BACKGROUND=images/main/search/top.png /> </TD />";
echo "<TD WIDTH=23 /><IMG SRC=images/main/search/topright.png /></TD />";
echo "</TR />";
echo "<TR />";
echo "<TD BACKGROUND=images/main/search/left.png />";
echo " ";
echo "</TD />";
echo "<TD BACKGROUND=images/main/search/bg.png />";












echo "<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH=100% />";
echo "<TR />";



echo "<TD valign=top width=30 />";

echo "<CENTER />";
echo "<A HREF=carpets.php?id=".$row['id']." />";
echo "<IMG SRC=".$row['imageloc']." width=100 height=100 border=0 />";
echo "</A />";
echo "</CENTER />";


echo "</TD />";







echo "<TD valign=top />";

echo "<CENTER />";
echo "<A HREF=carpets.php?id=".$row['id']." />";
echo $row['title'];
echo "</A />";
echo "</CENTER />";
echo "<BR />";
echo "<CENTER />";
echo "<FONT SIZE=4 />";
echo "£";
echo $row['price'];
echo " Per Square Metre";
echo "</FONT />";
echo "</CENTER />";



echo "</TD />";





echo "</TR />";
echo "</TABLE />";









echo "</TD />";
echo "<TD BACKGROUND=images/main/search/right.png />";
echo " ";
echo "</TD />";
echo "</TR />";
echo "<TR />";
echo "<TD WIDTH=23 /><IMG SRC=images/main/search/bottomleft.png /></TD />";
echo "<TD BACKGROUND=images/main/search/top.png /> </TD />";
echo "<TD WIDTH=23 /><IMG SRC=images/main/search/bottomright.png /></TD />";
echo "</TR />";
echo "</TABLE />";
echo "<BR />";
}


?>


<!-- END OF CENTRAL RIGHT -->









<!-- END OF RIGHT HAND MAIN SIDE -->

</TD>

<TD WIDTH="10" valign="top"> </TD>

</TR>

</TABLE>



<BR><BR><BR><BR>
<CENTER><FONT SIZE="1" FACE="VERDANA">This Website was designed and is hosted by <A HREF="http://www.IRCDirect.co.uk">IRC Direct Website Services</A> - Copyright Supreme Carpets Ltd 2010 ©</FONT></CENTER>

<!-- END OF LOWER PART OF WEBSITE -->

<!-- END OF MAIN -->

</TD></TR></TABLE>



</BODY>

</HTML>

Link to comment
Share on other sites

The whole page loads with "price" changed to other columns in the sql table like type and colour.

 

it is VarChar preset in them too so there should be no reason to not load the price too.

 

http://www.ircdirect.co.uk/FTPServers/supremecarpets/carpetprice.php?price=<30.00

 

thats the link to the price page (which shows no arrays at all)

 

http://www.ircdirect.co.uk/FTPServers/supremecarpets/ thats the home page, click a colour or type to see what should happen.

 

Tricky one :(

 

ian

Link to comment
Share on other sites

it says:

 

SELECT * FROM carpets WHERE price = ''

 

it looks like valid sql as:

 

$what_price=$_GET['price'];
$query="SELECT * FROM carpets WHERE price = '$what_type'";

$result = mysql_query($query) or die(mysql_error());


while($row = mysql_fetch_array($result)){

 

the $what_price gets the column "price"

 

it then querys the database to return results.

 

Weird... :S

Link to comment
Share on other sites

ahh i noticed it still said...

 

$what_price=$_GET['price'];
$query="SELECT * FROM carpets WHERE price = '$what_type'";

it said what "type"

 

i changed it to

 

$what_price=$_GET['price'];
$query="SELECT * FROM carpets WHERE price = '$what_price'";

 

now when i select the actual price... i.e:

 

http://www.ircdirect.co.uk/FTPServers/supremecarpets/carpetprice.php?price=17.88

 

it shows the product that is that exact price.

 

I wanted to query it for a price thats that... or less.

 

I.E:

 

http://www.ircdirect.co.uk/FTPServers/supremecarpets/carpetprice.php?price=<30.00

 

(Price... less than 30.00)

 

then it shows all items 30.00 or below.

 

Many Thanks,

 

Ian

 

 

Link to comment
Share on other sites

This way isn't super scalable but better than what you are trying.  Also, make sure to escape your data or you'll end up in very bad shape.

 

http://www.ircdirect.co.uk/FTPServers/supremecarpets/carpetprice.php?op=<&price=30.00

 

$what_op = mysql_real_escape_string($_GET['op']);
$what_price = mysql_real_escape_string($_GET['price']);
$query = "SELECT * FROM carpets WHERE price $what_op= '$what_price'";

 

Or maybe better:

 

http://www.ircdirect.co.uk/FTPServers/supremecarpets/carpetprice.php?min=0.00&max=30.00

 

$what_min = mysql_real_escape_string($_GET['min']);
$what_max = mysql_real_escape_string($_GET['max']);
$query = "SELECT * FROM carpets WHERE price BETWEEN $what_min AND $what_max";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.