Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8845185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:40:40+00:00 2026-06-14T11:40:40+00:00

my question is on adding the file paths to images to a user’s slot

  • 0

my question is on adding the file paths to images to a user’s slot in a database. here is a sample, this is the page where the photos are to be chosen:

   require_once("script.php");   
   <form method="post" action='golf.php'>
<?php
 require_once("golf_phot.php");
?>
</div>
<input id="butt" type="submit" value="add"/>
</form>

here are the contents of golf_phot.php:

$query="SELECT category_id FROM categories WHERE category_name='golf'";
$resultt=mysql_query($query);
$row=mysql_fetch_array($resultt);
$do=$row['category_id'];
$query2="SELECT photo FROM all_photos WHERE all_photos.category_id='$do'";
$result=mysql_query($query2); 
while ($row=mysql_fetch_array($result))
{
 $photo=$row['photo'];
 echo "<input type=\"checkbox\" name=\"addlist[]\" value=\"".$photo."\">"."<img    src=\"".$photo."\">";
echo "<br>";
echo "<br>";
echo "<br>";
}

i already did the mysql connection and database selection, i won’t post that but it has no issues. here are the contents of “script.php”:

if(isset($_POST['addlist']))
{
$pics=$_POST['addlist'];
$n=count($pics);
//now, to open the database user_info, using the stored session

//make the session variable legit
if(isset($_SESSION['user']))
{
$user=$_SESSION['user'];
}
//get the user's id from the user_info table
$querya="SELECT * FROM user_info WHERE user_info.fb_id='$user'";
$result1=mysql_query($querya);
//now that we have the id, we can add the photos to 
//user_photos, using their id as a foreign key
if(mysql_num_rows($result1)>0){
$rowa=mysql_fetch_array($result1);}
$user_id=$rowa['USER_INFO_ID'];
//before we add them, we'll need to see whether they exist or not.
//adding time:
for($i=0;$i<$n;$i++){
$data=$pics[$i];
$queryb="SELECT * FROM user_photos";
$result3=mysql_query($queryb);
if(mysql_num_rows($result3)>0){
while($rowa=mysql_fetch_array($result3))
{
$data2=$rowa['USER_PHOTOS'];
if($data==$data2)
{ $var='exists';   }
else{
$queryb="INSERT INTO user_photos(USER_PHOTOS_ID,USER_INFO_ID,USER_PHOTOS) VALUES('NULL','".$user_id."','".$data."')";
$result2=mysql_query($queryb);
}
}
}
}

// selected photos added to user’s gallery!
}
the user data variables are all set as i use them elsewhere and they are successfuly added to the database, above, i include a way to see if the photo already exists, i don’t add it if it does(maybe there’s an issue with that?) so basically, the page with photos is loaded, the user checks on the photos they want and then they send it to the same page, where “script.php” is supposed to process the data and add it to the database. no photos are added to the database, i really can’t tell what’s the issue here. i kindly ask for help, even though this is probably an easy question, if you need me to clarify something, kindly ask so, meanwhile, can anybody help? thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:40:41+00:00Added an answer on June 14, 2026 at 11:40 am

    Please Try this code in your script.php. hoping this may work for you.
    I Have removed the condition if(mysql_num_rows($result3)>0){

    Code:

    if(isset($_POST['addlist']))
        {
        $pics=$_POST['addlist'];
        $n=count($pics);
        //now, to open the database user_info, using the stored session
    
        //make the session variable legit
        if(isset($_SESSION['user']))
        {
        $user=$_SESSION['user'];
        }
        //get the user's id from the user_info table
        $querya="SELECT * FROM user_info WHERE user_info.fb_id='$user'";
        $result1=mysql_query($querya);
        //now that we have the id, we can add the photos to 
        //user_photos, using their id as a foreign key
        if(mysql_num_rows($result1)>0){
        $rowa=mysql_fetch_array($result1);}
        $user_id=$rowa['USER_INFO_ID'];
        //before we add them, we'll need to see whether they exist or not.
        //adding time:
        for($i=0;$i<$n;$i++){
        $data=$pics[$i];
        $queryb="SELECT * FROM user_photos";
        $result3=mysql_query($queryb);
    
        while($rowa=mysql_fetch_array($result3))
        {
        $data2=$rowa['USER_PHOTOS'];
        if($data==$data2)
        { $var='exists';   }
        else{
        $queryb="INSERT INTO user_photos(USER_PHOTOS_ID,USER_INFO_ID,USER_PHOTOS) VALUES('NULL','".$user_id."','".$data."')";
        $result2=mysql_query($queryb);
        }
    
        }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've found this question on StackOverflow Adding div below images in colorbox But it
I had asked this question Adding more attributes to LINQ to SQL entity Now,
This is in relation to this question . The proposed answers involve adding a
I am trying to upload some images and adding them div container. My question
This seems like such an obscure question, but here it goes: Is there a
Fresh Asking of this Question-> I have a WIX file that I need to
This is actually a question about this question: Adding a directory to $LOAD_PATH (Ruby)
I'm following this tutorial and although adding it to the Gem file and bundle
I have asked similar question for Linux RPM ( Adding License Agreement in RPM
I've a question concerning handling touch events for CustomView .I'm adding custom view's dynamically

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.