Jump to content

[HELP] Making a simple multiply script - not so simple :(!


colleyboy

Recommended Posts

Hi pplz...

 

I am designing a carpet website for a friend but am having a problem.

 

http://www.ircdirect.co.uk/FTPServers/supremecarpets/carpets.php?id=1

 

On this page ^^^ I want to make a simple script so that a person can enter a number, press calculate and it calculates the cost of the flooring.

 

I.E: This flooring is: £17.88 per metre (its stored in the database under price). 

 

maybe something like:

 


<?PHP 

echo "<FORM><input type=input></FORM>*.$row['imageloc'].";
echo"<INPUT TYPE=SUBMIT></FORM";

?>

 

TBH I dont know, any help is very much appreciated as google couldnt help :(

 

Many Thanks,

 

Ian

Link to comment
Share on other sites

If you are having difficulty with this it may behoove you to pick up a beginners MySQL/PHP book.  Alls you are doing is taking a POST value, doing a query against the database, multiplying the two values, and displaying the result to the user.

Link to comment
Share on other sites

Well so far I have done the following:

 

$a=$row['price'];
$b=area;
$total=$a*$b;

echo "<FORM action=carpets.php?id=".$row['id']." method=post />";
echo "<input type=text name=area WIDTH=30 />";
echo "<input type=submit value=Calculate values />";
echo "</FORM />";

 

but for some reason when the page refreshes it doesn't come back with any value... still "0"  always at the moment.

 

Any help?

Link to comment
Share on other sites

Sorry, but negative critisism isnt helpful.  I can only do my best.  I came on here for help... not for people to write scripts for me, but to help me correct any mistakes.  I am only human.

 

This is the script 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>

<IMG SRC="images/main/search/colours/creme.png" title="Cream, Ivory"> <IMG SRC="images/main/search/colours/biege.png" title="Beige"> <IMG SRC="images/main/search/colours/brown.png" title="Brown"><BR>

<IMG SRC="images/main/search/colours/lilac.png" title="Lilac, Purple"> <IMG SRC="images/main/search/colours/blue.png" title="Blue"> <IMG SRC="images/main/search/colours/black.png" title="Grey, Black, Silver"><BR>

<IMG SRC="images/main/search/colours/green.png" title="Green"> <IMG SRC="images/main/search/colours/yellow.png" title="Yellow, Gold"> <IMG SRC="images/main/search/colours/red.png" title="Orange, Red, Terracotta, Burgundy, Peach, Pink"><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_id=$_GET['id'];
$query="SELECT * FROM carpets WHERE id = '$what_id'";

$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=200 VALIGN=top />";




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 "<A HREF=".$row['imageloc']." target=_blank />";
echo "<IMG SRC=".$row['imageloc']." width=200 height=200 border=0 />";
echo "</A />";


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 "</TD />";


echo "<TD width=5 />";
echo " ";
echo "</TD />";



echo "<TD / VALIGN=top>";


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 "<CENTER />";
echo "<U />";
echo $row['title'];
echo "</U />";
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 "<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 />";


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 "<CENTER />";
echo "<U />";
echo "Flooring Cost Calculator";

$a=$row['price'];
$b=area;
$total=$a*$b;

echo "<FORM action=carpets.php?id=".$row['id']." method=post />";
echo "<input type=text name=area WIDTH=30 />";
echo "<input type=submit value=Calculate values />";
echo "</FORM />";


echo "</U />";


echo "$total";

echo "</CENTER />";

echo "<BR />";



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 "</TD />";
echo "</TR />";
echo "</TABLE />";

echo "<BR />";






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 "<CENTER />";
echo "<U />";
echo "Description";
echo "</U />";
echo "</CENTER />";

echo "<BR />";

echo "<CENTER />";
echo $row['description'];
echo "</FONT />";
echo "</CENTER />";

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 />";


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













}

?>

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

 

Thats the whole page. 

 

I am stuck... and don't know whats wrong.

 

Ian

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.