Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

A variable RADIO BUTTON`S VALUE

General discussions related to php

Moderators: macek, egami, gesf

A variable RADIO BUTTON`S VALUE

Postby NabilChicago » Wed May 07, 2003 7:45 pm

I`m trying to build a store that shows the products with a radio button in the side for each product, if you select one of the product`s radio button and fill the quantity field and submit you should go to purchase.php that is gonna print the product Id, shows the picture of the product, the price.

store.php

<html>
<head>
<title>Welcome To The Store!!!</title>
<SCRIPT LANGUAGE = "JavaScript">

function checkform()
{
nabil_quantity = document.npro.quantity.value;
p = 0;
while(p < nabil_quantity.length) {
nabil_quantitychar =nabil_quantity.substring(p, p+1);

if((nabil_quantitychar < '0') || (nabil_quantitychar > '9'))
{
alert("Enter a number");
document.npro.quantity.value ="";
document.npro.quantity.focus();
return false;
}
p++
}
if(document.npro.quantity.value < 1 || document.npro.quantity.value > 999)
{
alert("Please enter a number between 1 and 999");
document.npro.quantity.value ="";
document.npro.quantity.focus();
return false;
}
return true;
}
</script>


<script type="text/javascript">
<!-- script créé par le webmaster de : -->
<!-- http://www.creation-de-site.net -->
<!-- vous y trouverez des javascripts, des images, des tutoriaux et des ressources gratuites. -->
<!--
function open_window(votre_page)
{
var hauteur_popup=400;
var H = (screen.height - hauteur_popup) / 2;
var largeur_popup=300;
var L = (screen.width - largeur_popup) / 2;
pop_up = window.open(votre_page,"Popup","status=yes,scrollbars=yes,resizable=no,height="+hauteur_popup+",width="+largeur_popup+",top="+H+",left="+L);
}
//-->
</script>

</head>

<body>


<?php
print "<center>";
print " <img src='menu.gif' width='460' height='165' border='0' usemap='#FPMap0'>";

print " <map name='FPMap0'>";
print " <area href='store.php?username_in=$username_in' shape='rect' coords='12, 15, 65, 40'>";
print " <area href='aboutus.php?username_in=$username_in' shape='rect' coords='84, 18, 161, 40'>";
print " <area href='faqs.php?username_in=$username_in' shape='rect' coords='292, 122, 342, 138'>";
print " <area href='contactus.php?username_in=$username_in' shape='rect' coords='357, 119, 448, 140'>";
print " </map>";


print "<table COLS=4 WIDTH='75%'><tr><td width='40%'> <form action='store.php'method='post'>";

print "<input type='text' name='SearchString' value='' size='25'><BR><BR> <input type='submit' value='Search'>";

print "<input type='hidden' name='status' value='active'> </form></td>";





$Host = "db2.phenominet.com";

$User = "buchheitstudent8";

$Password = "perfectscore";

$DBName = "buchheitstudent8";

$TableName = "raja_products";

$FoundFlag = 0;



$link = mysql_connect ($Host, $User, $Password);

$result=mysql($User,"select * from $TableName");

$num_of_recs = mysql_numrows($result);

$ctr = 0;

if ($ptr == "") $ptr = 0;

$recnum = $ptr;


print "<form name='npro' method='POST' action='purchase.php' onSubmit='return checkform()'>";


While (($ctr < 3) && ($recnum < $num_of_recs))

{

$ProdName = mysql_result($result,$recnum,"productName");

$ProdDesc = mysql_result($result,$recnum,"productDesc");

$ProdId = mysql_result($result,$recnum,"productId");

$ProdPrice = mysql_result($result,$recnum,"productPrice");

$ProdImage = mysql_result($result,$recnum,"productImage");

$KW = mysql_result($result,$recnum,"productKW");


if ($SearchString == "" || eregi($SearchString, $KW))

// WHY?

{

$FoundFlag = 1;

$ProdNme = urlencode($ProdName);

$ProdDsc = urlencode($ProdDesc);

$ProdImg = "+$ProdImage+";



print "<a href=JavaScript:open_window('detail.php?prodId=$ProdId&prodPrice=$ProdPrice&prodName=$ProdNme&prodDesc=$ProdDsc&prodImage=$ProdImg')";

// THEN PRINT THE IMAGE, ID, NAME, AND PRICE

print "<br><img SRC=$ProdImage height = 100 width = 100</a>";

print "<br><input type=radio ";

if ($ctr == 0) print "checked "; // ???

print "name=productId2 value=$ProdId"; // ???


print "<br><br>$ProdName<br>";

$ctr=$ctr+1;

}

// YOU MUST INCREMENT $ctr AND $recnum -- BUT WHERE?

$recnum=$recnum+1;

}

mysql_close($link);


print "<br>";

print "<center>";

if ($FoundFlag == 1)

{print "<font size=4>Enter Quantity: </font>";

print "<input type='text' name='quantity' size=6 value='1'>";

print "&&&";

print "<center>";

print "<BR>";

print "<input type='submit' value='Submit'>";

print "</center>";

}

//print "<BR><BR>";

print "</form>";

if ($recnum < $num_of_recs)

{print "<a href=store.php?ptr=$recnum&status=active&SearchString=$SearchString>";

print "<B><font size +4>Next Page</a>";

print "&&&";

}

if (($ptr == 0) & ($SearchString == ""))

{print "<a href='entry.html'";

print "<font size +4>Return to Entry Page</a>";

}

if ($FoundFlag == 0)

{print "<br> Sorry, there are no more matches for your request.";

}

?>


</body>
</html>


purchase.php

[size=12]<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php

print "<body>";
print "<center>";
print " <img src='menu.gif' width='460' height='165' border='0' usemap='#FPMap0'>";

print " <map name='FPMap0'>";
print " <area href='store.php?username_in=$username_in' shape='rect' coords='12, 15, 65, 40'>";
print " <area href='aboutus.php?username_in=$username_in' shape='rect' coords='84, 18, 161, 40'>";
print " <area href='faqs.php?username_in=$username_in' shape='rect' coords='292, 122, 342, 138'>";
print " <area href='contactus.php?username_in=$username_in' shape='rect' coords='357, 119, 448, 140'>";
print " </map>";


if ($productId2 = $ProdId)


$total = $ProdPrice * $quantity;


{
print "<center>";
print "$ProdName<br>";
print "<img SRC=$ProdImage><br>";
print "$ProdId<br>";
print "$ProdDesc<br>";
print "$total";
}
?>

</body>
</html>
[/size]


the purchase.php doesn`t work and the store.php is a little bit messed up but the most important is puchase.php Thank You
NabilChicago
New php-forum User
New php-forum User
 
Posts: 5
Joined: Sat Apr 05, 2003 7:51 pm
Location: Chicago

Postby Redcircle » Tue May 20, 2003 1:05 am

You have to elaborate a little more. When you say it doesn't work do you get any errors.. are you using superglobals? is everything spelled correctly
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA


Return to PHP General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron