Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Creating some dropdowns in checkout
Old 09-08-2010, 01:51 PM Creating some dropdowns in checkout
lsdjedi's Avatar
Novice Talker

Posts: 13
Trades: 0
If I were going to create a ecommerce checkout in my Wordpress website that had 3 spots to put in numbers (measurements for furniture) and a color selection spot how would I go about doing this?
__________________
The last forum I used for website help had 11 people in the PHP Forum when I last went in... When I joined this site there was 697 people in the PHP Forum... Awesomeeee<3
lsdjedi is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-09-2010, 10:42 AM Re: Creating some dropdowns in checkout
Banned

Posts: 408
Name: mushget
Trades: 0
HTML Code:
<html>
<head>
<script type="text/javascript">
function showUser(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>

<form>
<select name="users" onchange="showUser(this.value)">
<option value="">Select a person:</option>
<option value="1">Peter Griffin</option>
<option value="2">Lois Griffin</option>
<option value="3">Glenn Quagmire</option>
<option value="4">Joseph Swanson</option>
</select>
</form>
<br />
<div id="txtHint"><b>Person info will be listed here.</b></div>

</body>
</html> 



The PHP File

The page on the server called by the JavaScript above is a PHP file called "getuser.php".
The source code in "getuser.php" runs a query against a MySQL database, and returns the result in an HTML table:
PHP Code:
<?php
$q
=$_GET["q"];

$con mysql_connect('localhost''peter''abc123');
if (!
$con)
  {
  die(
'Could not connect: ' mysql_error());
  }

mysql_select_db("ajax_demo"$con);

$sql="SELECT * FROM user WHERE id = '".$q."'";

$result mysql_query($sql);

echo 
"<table border='1'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
<th>Hometown</th>
<th>Job</th>
</tr>"
;

while(
$row mysql_fetch_array($result))
  {
  echo 
"<tr>";
  echo 
"<td>" $row['FirstName'] . "</td>";
  echo 
"<td>" $row['LastName'] . "</td>";
  echo 
"<td>" $row['Age'] . "</td>";
  echo 
"<td>" $row['Hometown'] . "</td>";
  echo 
"<td>" $row['Job'] . "</td>";
  echo 
"</tr>";
  }
echo 
"</table>";

mysql_close($con);
?>

Last edited by chrishirst; 09-14-2010 at 02:44 PM..
mushget is offline
Reply With Quote
View Public Profile Visit mushget's homepage!
 
Reply     « Reply to Creating some dropdowns in checkout
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09703 seconds with 12 queries