Jump to content

HELP please... Images on array showed in Multicolumn format with Radio Buttons


Recommended Posts

Hi guys.

 

First off thank you to everyone in this site for all the help that only reading has been to me.

I am a TOTAL newbie on PHP so please bear with me.

Second off .. I would like to explain to you what i am trying to do...

The office executive comes into our site and registers himself on the member part of it.

What i am trying to do is for every executive to have the option of choosing an image from all the images that are in the images folder that are pulled from the database.

The database has a table called picks which has 2 fields. ID - INT - AutoInc and fname - char - 255 which in turn is the full name of the image.

Now i am trying to on the signup page to of course ask to everything needed no biggie here .. and after that .. to show on a table (from an array) the images which it does already but i have no idea how to approach on how to create the radio button. Because when the radio buttons are displayed only the first one and the last one coincide .. You see .. the images table follows an order from top to bottom and then from left to right .. but the buttons are following a different order ... from left to right then top to bottom.. making accurate only the first and the last button ... for him/her to check on it and then put the name of that image into his/her member table.

 

This is my code so far ..

<?
include 'include/func.php';
?>
<html>
<head>
<title>Sign Up for a New Member</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php

function sql_safe($s)
{
if (get_magic_quotes_gpc())
$s = stripslashes($s);

return mysql_real_escape_string($s);
}


if(isset($_POST['add']))
{

//This is the directory where images will be saved
$target = "call_images/";
$target = $target . basename( $_FILES['photo']['name']);



$username = $_POST['username'];
$password = $_POST['password'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email_ = $_POST['email_'];
$email_2 = $_POST['email_2'];
$radioOption = $_POST['$radioOption'];
$pic=($_FILES['photo']['name']);


include 'include/func.php';

$query = "INSERT INTO amember_control (fname, lname, email, pix, password) VALUES ('$fname', '$lname', '$email_', '$radioOption', '$password')";
mysql_query($query) or die('Error, insert query failed');

//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{

//Tells you if its all ok
echo "The file ".
basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
}
else {

//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}


include 'include/closedb.php';
echo "New Member has been added";
}
else
{
?>
<form action="" method="post" enctype="multipart/form-data" name="uploadform">
<table width="470" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="116">First Name:</td>
<td colspan="2"><input name="fname" type="text" id="fname"></td>
</tr>
<tr>
<td width="116">Last Name:</td>
<td colspan="2"><input name="lname" type="text" id="lname"></td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
</tr>
<tr>
<td width="116">Email:</td>
<td colspan="2"><input name="email_" type="text" id="email_"></td>
</tr>
<tr>
<td>Re-Type Email:</td>
<td colspan="2"><input name="email_2" type="text" id="email_2"></td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
</tr>
<tr>
<td>Password:</td>
<td colspan="2"><input name="password" type="password" id="password"></td>
</tr>
<tr>
<td>Re-Type Pass:</td>
<td colspan="2"><input name="password2" type="password" id="password2"></td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
</tr>
<?php
$columns = 3;
$query = "SELECT id, fname, photo FROM picks ORDER BY fname";
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);
$rows = ceil($num_rows / $columns);
echo '<ul>';
while($row = mysql_fetch_array($result)) {
$data[] = "<img src=http://www.xxxxx.com/aMember/call_images/".$row['photo'] .">";
//store the other field into an array
$data2[] = $row['fname'];
$data3[] = $row['id'];
}
echo "<TABLE BORDER=\"1\" cellpadding=0 cellspacing=10>\n";
$e=0;
for($i = 0; $i < $rows; $i++) {
echo "<TR>\n";
for($j = 0; $j < $columns; $j++) {
if(isset($data[$i + ($j * $rows)])) {
echo "<TD align=center>" . $data[$i + ($j * $rows)] . "
";

$e<=count($data2);
echo("<input type=\"radio\" name=\"radioOption\" value=\"" . $e . "\" id=\"option" . $e . "\"><label for=\"option" . $e . "\">" . $data2[$e] . "</label>");
$e++;

}
}
echo "</TR>\n";
}
echo "</TABLE>\n";
echo '</ul>';
$id = $_POST['id'];
include 'include/closedb.php';
?>
<tr>
<td width="116">Picture</td>
<td> </td>
<td><input type="hidden" name="MAX_FILE_SIZE" value="2000000"><input name="photo" type="file" class="box" id="photo"></td>
</tr>
<tr>


<td width="116"> </td>
<td colspan="2"><input name="add" type="submit" id="add" value="Add New User"></td>
</tr>
</table>
</form>
<?php
}
?>

</body>
</html>

 

Sorry about the big post guys.

Thanks in advanced for all the help.

Have a great weekend everyone.

Ed

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.