PHP PROGRAMMING FORM DISPLAY URGENT HELP NEEDED?
Hey everyone I have been having this problem all I want to do is query the database then put my variables into a form for example
Select size<br />
<select id=’ldkdk’ onmousedown=’show(this.value)’>
<option value=’$show’>$jjsjs</option>
</select>
<input type=’button’ onClick =’ksksk(jksjsks)’ >
<input type=’text’ id=’data’ size=’20′>
</form>
I am very annoyed as every time i put the variable into the form it turns into two or three forms depending on what data is chosen from the database and all i want is one form with an option to pick a something please can some one help me? I have already tried to exlode the variable but its not working
$qursize = "SELECT * FROM size WHERE caps = ‘$img’";
$resize = mysql_query($qursize) or die(mysql_error());
while($rs = mysql_fetch_array($resize))
{
$size = $rs[size];
$show = "$img,$size,";
$expls = explode(" ", $size);
echo"
<head>
<script type=’text/javascript’ src=’call_cart.js’></script>
<script type=’text/javascript’ src=’call_size.js’></script>
</head>
<body>
<div id=’outofstock’></div>
<form>
Select size<br />
<select id=’sizel’ onmousedown=’showstock(this.value)’>
<option value=’$show’>$expls[0]</option>
<option value=’$show’>$expls[1]</option>
<option value=’$show’>$expls[2]</option>
<option value=’$show’>$expls[3]</option>
<option value=’$show’>$expls[4]</option>
</select>
<input type=’button’ onClick =’showUser(sizel.value)’ >
<input type=’text’ id=’data’ size=’20′>
</form>
OR
$qursize = "SELECT * FROM size WHERE caps = ‘$img’";
$resize = mysql_query($qursize) or die(mysql_error());
while($rs = mysql_fetch_array($resize))
{
$size = $rs[size];
$show = "$img,$size,";
echo"
<head>
<script type=’text/javascript’ src=’call_cart.js’></script>
<script type=’text/javascript’ src=’call_size.js’></script>
</head>
<body>
<div id=’outofstock’></div>
<form>
Select size<br />
<select id=’sizel’ onmousedown=’showstock(this.value)’>
<option value=’$show’>$size</option>
</select>
<input type=’button’ onClick =’showUser(sizel.value)’ >
<input type=’text’ id=’data’ size=’20′>
</form>
and infact i am having a problem with the html form part of my php script itis with the display!
Your problem is caused by having it all inside the while loop. Also if your only calling data from one row you do not need a loop.
$row = mysql_fetch_array(mysql_query("SELECT * FROM size WHERE caps = ‘$img’"));
$size = $row[size];
$expls = explode(" ", $size);
echo"
<html>
<head>
<script type=’text/javascript’ src=’call_cart.js’></script>
<script type=’text/javascript’ src=’call_size.js’></script>
</head>
<body>
<div id=’outofstock’></div>
<form> Select size
<select id=’sizel’ onmousedown=’showstock(this.value)’>
<option value=’$show’>$expls[0]</option>
<option value=’$show’>$expls[1]</option>
<option value=’$show’>$expls[2]</option>
<option value=’$show’>$expls[3]</option>
<option value=’$show’>$expls[4]</option>
</select>
<input type=’button’ onClick =’showUser(sizel.value)’ >
<input type=’text’ id=’data’ size=’20′>
</form>
</body>
</html>
Your problem is caused by having it all inside the while loop. Also if your only calling data from one row you do not need a loop.
$row = mysql_fetch_array(mysql_query("SELECT * FROM size WHERE caps = ‘$img’"));
$size = $row[size];
$expls = explode(" ", $size);
echo"
<html>
<head>
<script type=’text/javascript’ src=’call_cart.js’></script>
<script type=’text/javascript’ src=’call_size.js’></script>
</head>
<body>
<div id=’outofstock’></div>
<form> Select size
<select id=’sizel’ onmousedown=’showstock(this.value)’>
<option value=’$show’>$expls[0]</option>
<option value=’$show’>$expls[1]</option>
<option value=’$show’>$expls[2]</option>
<option value=’$show’>$expls[3]</option>
<option value=’$show’>$expls[4]</option>
</select>
<input type=’button’ onClick =’showUser(sizel.value)’ >
<input type=’text’ id=’data’ size=’20′>
</form>
</body>
</html>
References :