Jump to content

Recommended Posts

Hey guys,

ive simply have a table printed with all the page details on.

the fields are shown on the 2nd part of the php script bellow.

 

The print works fine, all $i increase each row....

 

the problem is when its posted,

for some reason the posts aren't coming through correctly or nothing..

the count only counts 1,

and update doesnt do anything, but it apparently runs correctly as it print UPDATED..

 

I'm pretty sure its a minor mess up, but i'm using trial and error and getting no where.

 

any guidance would be much appreciated!!

Cheers,

Ben.

 

include_once "connect_to_mysql.php";

//////////SPupdate

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

$size = count($_POST['id']);

print 'Count: '.$size.'';

$i = 0;

 

while ($i < $size) {

 

// define each variable

$pmainp_id= $_POST['pmainp_id'][$i];

$porder_no = $_POST['porder_no'][$i];

$pname = $_POST['pname'][$i];

$plink = $_POST['plink'][$i];

$ppage = $_POST['ppage'][$i];

$id = $_POST['id'][$i];

 

 

$query = mysql_query("UPDATE pages SET mainp_id = '$pmainp_id', order_no='$porder_no', name = '$pname', link='$plink', page = '$ppage' WHERE subp_id = '$id' LIMIT 1");

print"".$pname." UPDATE<br/>";

++$i;

 

}

if($query){

print "UPDATED";

}

else{

print "UPDATE FAIL";

}

}

 

////////////////////////////////////////////////////////////////////////////

/////////  SUB PAGES

////////////////////////////////////////////////////////////////////////////

$subopageget = mysql_query("SELECT * FROM pages ORDER BY mainp_id, order_no ASC");

$i = 1;

while ($srow = mysql_fetch_array($subopageget)){

$subp_id = $srow['subp_id'];

$mainp_id = $srow['mainp_id'];

$link = $srow['link'];

$name = $srow['name'];

$order_no = $srow['order_no'];

$page = $srow['page'];

$subpagerow .= '

<input type="hidden" name="id[$i]" id="id[$i]" value"'.$subp_id.'" />

<tr>

    <td><input name="pmainp_id[$i]" type="text" value="'.$i.' - '.$mainp_id.'"/></td>

    <td><input name="porder_no[$i]" type="text" value="'.$order_no.'"/></td>

    <td><input name="pname[$i]" type="text" value="'.$name.'"/></td>

    <td><input name="plink[$i]" type="text" value="'.$link.'"/></td>

    <td><input name="ppage[$i]" type="text" value="'.$page.'"/></td>

  </tr>

';

++$i;

}

 

Link to comment
https://forums.phpfreaks.com/topic/200020-simple-update-while-confusion/
Share on other sites

Cheers for the reply.

I've changed the $i as suggested

 

$subpagerow .= '

<input type="hidden" name="id['.$i.']" id="id['.$i.']" value"'.$subp_id.'" />

<tr>

    <td><input name="pmainp_id['.$i.']" type="text" value="'.$mainp_id.'"/></td>

    <td><input name="porder_no['.$i.']" type="text" value="'.$order_no.'"/></td>

    <td><input name="pname['.$i.']" type="text" value="'.$name.'"/></td>

    <td><input name="plink['.$i.']" type="text" value="'.$link.'"/></td>

    <td><input name="ppage['.$i.']" type="text" value="'.$page.'"/></td>

  </tr>

';

 

 

which now produces the correct $size variable, but still the update isnt actually updating.

 

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.