I am trying to save crafts that I have displayed by clicking on an image that is in the container of the craft. I have all the functions working to start a php script and write the user_id of the person logged in, but I’m not sure how to pull the craft_id specific to the craft I’m trying to save. Any suggestions?
[php]
PAGE 1
while($row = mysqli_fetch_array($result))
{
$id = $row[‘id’];
$title = $row[‘title’];
$image = $row[‘imagesmall’];
$image2 = $row[‘imagelarge’];
$owner = $row[‘owner’];
$time = $row[‘time’];
$price = $row[‘price’];
$skill = $row[‘skill’];
$result2 = mysqli_query($mysqli ,"SELECT * FROM craft_materials WHERE craft_id='$id'");
$result3 = mysqli_query($mysqli ,"SELECT * FROM craft_tools WHERE craft_id='$id'");
$result4 = mysqli_query($mysqli ,"SELECT * FROM craft_category WHERE craft_id='$id'");
include 'popup_modal.php';
if ($i <= 3) //load the larger images
{
echo '<div id="craftlarge">';
echo '<div id="craftlargeimage">';
echo "<a href='#openModal".$title."".$id."'><img src=\"".$image2."\" width=270 height=270></a>";
echo "</div>";
echo '<div id="crafttitle">';
echo "$title";
echo "</div>";
echo '<div id="craftowner">';
echo "$owner";
echo "</div>";
echo '<div id="save">';
echo "<img onClick='save()' src='../resources/images/save_alt.png' style='cursor:pointer'>";
echo '</div>';
echo nl2br($body);
echo "</div>";
$i++;
$a++;
}
else if ($i <= 11) //load the smaller images
{
echo '<div id="craftsmall">';
echo '<div id="craftsmallimage">';
echo "<a href='#openModal".$title."".$id."'><img src=\"".$image."\"></a>";
echo "</div>";
echo '<div id="openModal" class="modalDialog">';
echo '<div>';
echo '<a href="#close" title="Close" class="close">x</a>';
echo "<img src=\"".$image2."\">";
echo '</div>';
echo '</div>';
echo '<div id="crafttitle">';
echo "$title";
echo "</div>";
echo '<div id="craftowner">';
echo "$owner";
echo "</div>";
echo '<div id="save">';
echo "<img onClick='save()' src='../resources/images/save_alt.png' style='cursor:pointer'>";
echo '</div>';
echo nl2br($body);
echo "</div>";
$i++;
$a++;
}
else if($i > 11) //reset counter to repeat craft loading
{
$i=1;
}
}
PAGE 2
$user = $_SESSION[‘user_id’];
$craft = $_SESSION[‘craft’];
mysqli_query($mysqli,"INSERT INTO saved_content (user_id, craft_id)
VALUES
('$user','$craft')");[/php]