only1wizard
asked on
onclick show form
i've created this form element in javascript and layed the table out in php but the only thing that is working is the hyperlink.
thanks in advance for your help!
thanks in advance for your help!
<?php require_once('Connections/Del_Comments.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO ascomments (Id, Memo, `Date`) VALUES (%s, %s, now())",
GetSQLValueString($_POST['Id'], "int"),
GetSQLValueString($_POST['Memo'], "text"));
mysql_select_db($database_Del_Comments, $Del_Comments);
$Result1 = mysql_query($insertSQL, $Del_Comments) or die(mysql_error());
$Cfk = mysql_insert_id();
$UId = '2';
$insertSQL = sprintf("INSERT INTO asmanystatusupdate (Id, SFk, CFk, CFk0, UIdFk0, UIdFk1, Dates) VALUES (%s, %s, '$Cfk', '$Cfk', '$UId', '$UId', now())",
GetSQLValueString($_POST['Id'], "int"),
GetSQLValueString($_POST['SFk'], "int"));
mysql_select_db($database_Del_Comments, $Del_Comments);
$Result1 = mysql_query($insertSQL, $Del_Comments) or die(mysql_error());
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script>
function showF(f){
if(document.getElementById(f).style.display=='none'){
document.getElementById(f).style.display='inline';
}
else{document.getElementById(f).style.display='none';}
}
</script>
</head>
<body>
<?php
//c.sfk={$row['sfk']}
mysql_select_db($database_Del_Comments, $Del_Comments);
$result = sprintf("SELECT a.Id, a.Type,
a.Dates,
a.UIdFk as UIdFk,
b.Id as Did,
b.comment as Comment,
b.dates as Day,
b.sfk as Sfk ,
aes_decrypt(e.ProfileName, '$Ukey') as Name,
substr(i.Path, 4) as Path
FROM
asstatusupdate as a
left join asstatusdata as b
on a.id = b.sfk
right join ASWebInfo as e
on e.Uidfk = a.uidfk
right join ASManyAlbums as f
on f.UserId=a.uidfk
right join ASAlbums as g
on f.AlbumId=g.Id
right join ASTitle as h
on g.Id=h.AlbumId
right join ASData as i
on h.Id=i.TitleId
where a.uidfk in (select friendid from asfriends where uidfk0='1') and i.DefaultProfilePic='Y' order by dates desc;
");
$statusUpdate = mysql_query($result, $Del_Comments) or die(mysql_error());
$category_id = '';
echo '<table align="center" width="40%" border="3" cellpadding="0" cellspacing="0">';
while($row = mysql_fetch_array($statusUpdate)) {
if ($row['Id'] != $category_id) {
$category_id = $row['Id'];
// grab table variables
$Type = $row['Type'];
$Dates = $row['Dates'];
$Comment = $row['Comment'];
$Name = $row['Name'];
$Path = $row['Path'];
$FriendId = $row['UIdFk'];
$SFK = $row['Sfk'];
echo '<tr>';
echo ' <td align="center">', $Name, '<br><a href="source/source.php?FriendId=',$FriendId,'"><img src="',$Path,'" height="120" width="120" align="middle" border="3" /></a></td>';
echo ' <td align="center"> ',$Dates,'<br><br>',$Type,'<br/>',$Comment,'</td>';
echo ' <td>',$category_id,'</td>';
echo ' <td>',$SFK,'</td>';
echo '</tr>';
} // end of if
mysql_select_db($database_Del_Comments, $Del_Comments);
$comments= sprintf("SELECT
c.sfk as sfk1,
c.UIdFk0,
d.Memo as Memo,
d.Date as Dates1,
e.ProfileName,
substr(i.Path, 4) as Path
FROM
asmanystatusupdate as c
left join ascomments as d on d.id = c.cfk
right join ASWebInfo as e on e.Uidfk = c.uidfk0
right join ASManyAlbums as f on f.UserId=c.uidfk0
right join ASAlbums as g on f.AlbumId=g.Id
right join ASTitle as h on g.Id=h.AlbumId
right join ASData as i on h.Id=i.TitleId
where c.sfk={$row['Sfk']} AND c.uidfk0 in (select friendid from asfriends where uidfk0='1') and i.DefaultProfilePic='Y' order by dates desc;
");
$statusComments = mysql_query($comments, $Del_Comments) or die(mysql_error());
while($user_row = mysql_fetch_array($statusComments)){
// test the query
//if($row['sfk'] == $user_row['sfk'])
{
$Dates1 = $user_row['Dates1'];
$Memo = $user_row['Memo'];
$Name1 = $user_row['Name'];
$Path1 = $user_row['Path'];
$FriendId1 = $user_row['UIdFk0'];
$SFK1 = $user_row['sfk1'];
//row and cell for "outer" while
echo '<tr>';
echo '<td colspan="4" style="padding-left:1em;">';
// display table
echo '<table align="center" width="60%" border="3" cellpadding="0" cellspacing="0">';
echo '<tr>';
echo ' <td align="center">',$Name1,'<br/><a href="source/source.php?FriendId=',$FriendId1,'"><img src="',$Path1,'" height="120" width="120" align="middle" border="3" /></a></td>';
echo ' <td align="center" width="40%"> ',$Dates1,'<br/><br/><br/>',$Memo,'</td>';
echo ' <td>'.$catagory_id.'</td>';
echo ' <td>',$SFK1,'</td>';
echo '</tr>';
echo '</table>';
//end row and cell for outer while
// echo '</td>';
// echo '</tr>';
} // end of if
echo '<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">';
echo '<a href="#" onclick="showF(' .'f1'. ');return false" style="position:relative">part 1</a><br>';
echo '<div id="f1" style="position:relative;display:none">';
echo '<table align="center">';
echo '<tr valign="baseline">';
echo '<td nowrap="nowrap" align="right">Memo:</td>';
echo '<td><input type="text" name="Memo" value="" size="32" /></td>';
echo '</tr>';
echo '<tr valign="baseline">';
echo '<td nowrap="nowrap" align="right"> </td>';
echo ' <td nowrap="nowrap" align="right"> </td>';
echo ' </tr>';
echo '<tr valign="baseline">';
echo ' <td nowrap="nowrap" align="right"> SFK: "$SFK" </td>';
echo ' <td><input type="submit" value="Insert record" /></td>';
echo ' </tr>';
echo ' </table>';
echo '<input type="hidden" name="Id" value="" />';
echo '<input type="hidden" name="Id" value="" />';
echo ' <input type="hidden" name="SFk" value="$SFK" />';
echo ' <input type="hidden" name="MM_insert" value="form1" />';
echo '</form>';
echo '</div>';
} // end of while loop
}// end of main loop
echo '</table>';
?>
</body>
</html>
you need to have and escape escape your single quotes.
echo '<a href="#" onclick="showF('\f1\');return false" style="position:relative">part 1</a><br>';
ASKER
i've tried that and this is the error that i got: Parse error: syntax error, unexpected T_NS_SEPARATOR, expecting ',' or ';'
echo "<a href=\"#\" onclick=\"showF('f1');return false\" style=\"position:relative\">part 1</a><br>";
ASKER
i've gotten that to work but it only works with the first recordset out of 14. i.e. when i click on record 10 only record 14 opens / shows the form.
how do i resolve this issue?
also how do i get this link to show only on the last record of the second query for that id foreign key?
thanks in advance for your help!
how do i resolve this issue?
also how do i get this link to show only on the last record of the second query for that id foreign key?
thanks in advance for your help!
This is not something related to the syntax, you might need to change showF('f1'); to something like:
showF('$currentForm');
ASKER
i've changed that variable name and that has not changed anything.
What are you trying to accomplish exactly?
ASKER
im trying to get it to open for each last of the record id for the sub query (not the very last record).
i.e.
status update 1
comment
hyperlink 1 id
status update 2
comment
hyperlink 2 id
take a look at my previous comments.
i hope this help.
thanks in advance for your help.
theo werntz ii
i.e.
status update 1
comment
hyperlink 1 id
status update 2
comment
hyperlink 2 id
take a look at my previous comments.
i hope this help.
thanks in advance for your help.
theo werntz ii
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok that matter has been resolved. with showing the form.
now there is still this matter. it only shows for the top record. when i click on one hyper link say on record 5 it shows the form on record 14 and not on 5. i need it to show the record on all hyperlink records ids.
i've included an image of record set results for better understanding hopefully.
Do i need to create an array of forms or js?
thanks in advance for your help!
Untitled-Document.pdf
now there is still this matter. it only shows for the top record. when i click on one hyper link say on record 5 it shows the form on record 14 and not on 5. i need it to show the record on all hyperlink records ids.
i've included an image of record set results for better understanding hopefully.
Do i need to create an array of forms or js?
thanks in advance for your help!
Untitled-Document.pdf
I assume that your code should be something similar (not exact) to:
for ($i = 0; $i < 14; $i++)
{
echo "<a href=\"#\" onclick=\"showF('f$i');return false\" style=\"position:relative\">part $i</a><br>";
}
ASKER
it is displaying the hyperlink for each subquery record id. what its not doing is opening the form for each record set id hyperlink.
Please post your HTML result here.
ASKER
here is my html/php results on the attached file.
i did not use your last query because it loops 14 times in one record.
Untitled-Document.pdf
i did not use your last query because it loops 14 times in one record.
Untitled-Document.pdf
ASKER
attached file will show the record set layout and the part 1 link is the hyper link in question.
thanks in advance for your help!
Untitled-Document.pdf