Jump to content


Photo

Cant come up with a good title .. plz read.


  • Please log in to reply
3 replies to this topic

#1 iPixel

iPixel
  • Members
  • PipPipPip
  • Advanced Member
  • 496 posts

Posted 30 May 2006 - 08:47 PM

Basically i have a ton of Text boxes and hidden fields and i pass them onto another page...

here is how it looks so far >

// This pulls all the information if any exists.

Include('dbcon.php');

$mdl = $_GET['mdl'];

$query = "SELECT * FROM gallery_alts WHERE model = '$mdl'";
$sql = mysql_query($query) or die(mysql_error());
$result = mysql_fetch_assoc($sql);
$count = mysql_num_rows($sql);


// This is the form created based upon the amount of images that database contained.
// all the database table has is a model : img : and empty field for alt tag (text).

        <form action="savealts.php" method="post">
        <table cellpadding="0" cellspacing="2" class="Thumbnail" width="95%">
        <tr>
        <td bgcolor="9ABC4B" align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF">Image Name</font></td>
        <td bgcolor="9ABC4B" align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF">Alt Tag</font></td>
        </tr>
        <?
        $i=0;
            do  
            {
                $i++;
                ?>
                    <tr>
                    <td>
                    <font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">                    
                    <? echo $result['img']; ?>
                    </font>
                    </td>
                    <td>
                    <input type="text" value="<? echo $result['alt_tag']; ?>" id="x">
                    <input type="hidden" value="<? echo $result['img']; ?>" id="x">
                    </td>
                    </tr>
                <?
            }
        while($result = mysql_fetch_assoc($sql));
        ?>
        <tr>
        <td colspan="2">&nbsp;</td>
        </tr>
        <tr>
        <td colspan="2" align="center">
        <input type="submit" value="Save Alt Tags" class="savealtbutton">
        <input type="hidden" value="<? echo $count; ?>" id="count">
        </td>
        </tr>
        </table>
        </form>

Now my question is ...
1> is this ok ..
2> how can i pick up all these values on the next page savealts.php and place them into a table.

UPDATE gallery_alts SET alt_tag = 'alt tag text box value' WHERE model = 'xxxxx' AND img = 'img text box value'";

Hope im clear.. i bad at explaining myself.

Here is an Image of what the Alt Tag Form will look like...
[a href=\"http://www.pixelsexy.com/AltForm.jpg\" target=\"_blank\"]http://www.pixelsexy.com/AltForm.jpg[/a]
[a href=\"http://www.pixelsexy.com/MainShot.jpg\" target=\"_blank\"]http://www.pixelsexy.com/MainShot.jpg[/a]

#2 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 30 May 2006 - 11:23 PM

You can use as many hidden fileds as you want. To access them in the next page, just give them an array name
<input type="text" value="<? echo $result['alt_tag']; ?>" id="x" name="alt[]">
<input type="hidden" value="<? echo $result['img']; ?>" id="x" name="img[]">

in your next page, the img and alt variables will be normal php arrays
$alt_array = $_POST['alt'];
$img_array = $_POST['img'];

foreach ($alt_array as $alt){
........
}

NoGray.com


#3 iPixel

iPixel
  • Members
  • PipPipPip
  • Advanced Member
  • 496 posts

Posted 31 May 2006 - 12:50 PM

Ah.... very cool.

Thank You very much for your help.



Edted Part Below ==============

ok i understand how it works ... and i got it working fine.

1 small issue though ...

$mdl = $_POST['model'];
$alt_array = $_POST['alt'];
$img_array = $_POST['img'];

foreach ($alt_array as $alt)
     {
          CODE HERE
     }



in the part that says CODE HERE .... how can i use the info from both arrays to create a SQL statement like so :

$query = "UPDATE gallery_alts SET alts = '$alt_array element' WHERE model = '$mdl' AND img = '$img_array element'";

NOTE : Element 1 of $alt_array should correspond with Element 1 of $img_array.

Thanks again for helping

#4 iPixel

iPixel
  • Members
  • PipPipPip
  • Advanced Member
  • 496 posts

Posted 31 May 2006 - 02:02 PM

WooT !

got it ... i think this is a good way to do it ... unless there is a better way.

$i=0;
foreach ($alt_array as $alt)
    {
        echo $alt_array[$i];
        echo " - ";
        echo $img_array[$i];
        echo "<BR>";
        $i++;        
    }

Thanks Again !




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users