...

View Full Version : need help please...



techker
12-08-2008, 11:10 PM
hey guys im going nuts with this script!!lol

i have a script that pulls images from a database for the client to chose witch one he wants.

now i have a radio button next to the image in a form.that part is cool..the only thing is the script that gets the image name and inserts in the DB that does not get the image name..here is the script
select the image


<? $dbh = mysql_connect("localhost","_","tr") or die("There was a problem with the database connection.");
$dbs = mysql_select_db("techker_gymgraph", $dbh) or die("There was a problem selecting the categories.");

$type=$_POST['type'];


$sql = "SELECT *
FROM `gymball`
WHERE `type` = '$type' ";
$fileLIST=mysql_query($sql);
$file=$row['name'];
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>GymGraph</title>
</head>

<body>

<form action="add_pic1.php" method="post">
<p align="center"><u>Sélectionner UNE photo</u></p>
<table width="346" border="0" align="center" cellpadding="0" cellspacing="0">
<tr><? while($row = mysql_fetch_array($fileLIST)) { ?>
<td width="173"><?php echo '<a href="/Gymgraph/Gymgraph/gymball/'. $row['name'] .'" target="_blank">
<img src="/Gymgraph/Gymgraph/gymball/'. $row['name'] .'" border="0" alt="" width=115/>
</a>
<br />'; ?></td>
<td width="173"><label>
<input type="checkbox" name="pic" id="pic" value='<? $row['name'] ?>'/></label>
Selection de photo </label>
<label>
<input type="hidden" name="name" id="name" value='<? echo $row['name'] ?>'/>
<input type="hidden" name="ex" id="ex" value='gymball'/>
</label></td>

<? } ?>
</table>
<p>
<p>
<label>
<div align="center">
<select name="location" id="location">
<option value="pic1">1</option>
<option value="pic2">2</option>
<option value="pic3">3</option>
<option value="pic4">4</option>
<option value="pic5">5</option>
<option value="pic6">6</option>
<option value="pic7">7</option>
<option value="pic8">8</option>
</select>
Emplacement de la photo

</label>

<label>
<div align="center">
<input type="submit" name="submit" id="submit" value="Submit" />
</div>
</label>
<div align="center">
<p>Envoyer la sélection </p>
<p><img src="pics/gymgraph_loc.jpg" width="629" height="383" /> </p>
</div>
</p>
</form>
</body>
</html>

now the add pic


<?php

$pic=$_POST['pic'][0];
$location=$_POST['location'];
$name=$_POST['name'];
$exercice=$_POST['ex'];


mysql_connect("localhost", "", "tr") or die(mysql_error()) ;
mysql_select_db("techker_gymgraphpics") or die(mysql_error()) ;



//Writes the information to the database
mysql_query("INSERT INTO $location (exercice,name) ".
"VALUES ('$exercice','$name')");


//Tells you if its all ok
$id= mysql_insert_id();
echo "<p>This file has the following Database ID: <b>$id</b>";
echo "You'll be redirected to Home Page after (4) Seconds";
echo "<meta http-equiv=Refresh content=4;url=type.php>";

?>


the part i dont grab is the one were the add_pic1.php grabs the radio button selection and inserts the name of the pic i selected...

lokeshshettyk
12-09-2008, 12:50 PM
Which radio button were you referring to? I don't see any in your code

whizard
12-09-2008, 04:07 PM
1. You need to actually add the pic variable to your insert statement.

2. Why do you have the line $pic = $_POST['pic'][0] instead of $pic = $_POST['pic']?

HTH
Dan



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum