Jump to content

rpjd

Members
  • Posts

    66
  • Joined

  • Last visited

    Never

Everything posted by rpjd

  1. I have 10 cells in a table row withe this format echo "<tr><td>Cell1</td><td>Cell2</td><td>Cell3</td><td>Cell4</td><td>Counter1</td><td>Button1</td><td>Counter2</td><td>Button2</td><td>Counter3</td>Button3</tr>""; if(isset($_POST['Button2'])) $LineNo= reset(array_keys($_POST['Button2'])); gives me the line number of the button that was pressed. How do or can I using the array_keys insert something into Counter2 cell?
  2. Got the that working now thanks. My next hurdle now is to create a link to that file and insert it into a table cell on the page. The is the link $Link = "<a href='E:/wamp/www/Project/Changes/{$file}>{$Count['0']}</a>"; This is what I have so far, how do I get the link into the cell? $doc = new DomDocument; $doc->validateOnParse = true; $doc->Load('file.php'); $Id = $doc->getElementById('Cell{$changes[LineNo']}');
  3. This is the updated code but I am getting Warning: fopen(E:/wamp/www/Project/Changes/3.txt) [function.fopen]: failed to open stream: No such file or directory. The else statement is executing but the file isn't being created. $file = "E:/wamp/www/Project/Changes/".$LineNo.".txt"; if(file_exists($file)) { $handle = fopen($file,'a') or die("can't open file"); fwrite($handle, $Username); } else { $handle = fopen($file,'w') or die("can't open file");; fwrite($handle ,$Username); }
  4. Is it possible to open a file in append mode only if the file exists, otherwise open it in write mode? The code as it is creates and writes to the file in append mode when the file doesn't initially exist.
  5. This is my code $file = "E:/wamp/www/Project/Changes/".$LineNo.".txt"; if(file_exists($file)) { fopen($file,'a') or die("can't open file"); fwrite($file,$Username); } else { fopen($file,'w'); fwrite($file,$Username); }
  6. When one of the buttons is clicked, how do I submit the LineNo on the row a button is clicked? echo "<tr><td name='LineNo[]>LineNo</td><td>Reference</td><td>Text</td><td><a href='filename.txt'>1</a></td><td>button1</td> <td><a href='filename.txt'>2</a></td><td>Button2</td><td><a href='filename.txt'>9</a></td><td>Button3</td></tr>"; If I use onclick='submit('$LineNo['value']');' how do I access the LineNo using $_POST? $_POST['LineNo'] ?
  7. Each user type has a seperate counter and button. Initially all counters are zero. <tr><td>LineNo</td><td>Reference</td><td>Text</td><td>0</td><td>button1</td><td>0</td><td>Button2</td><td>0</td><td>Button3</td></tr> When a user (logged in) clicks the appropriate button for the first time, their Username and LineNo are inserted into a table for their user type. The table is queried, counting the users grouped by the Line no which becomes the counter for the User Type, the username is then written to a txt file, the counter becoming a link to the txt file. The result being like this: <tr><td>LineNo</td><td>Reference</td><td>Text</td><td><a href='filename.txt'>1</a></td><td>button1</td> <td><a href='filename.txt'>2</a></td><td>Button2</td><td><a href='filename.txt'>9</a></td><td>Button3</td></tr> As the counters are all initially 0, I need to create a link for the txt file including counter and insert it into the cell to replace the 0. I assume javascript is required to insert link into cell. Subsequent clicks by any user have no affect, no double-counting.
  8. Regarding the counter link, I only want the link to appear if the count is greater than 1. Would that need to be done with javascript?
  9. Sorry I didn't explain properly what I am trying to do. I am writing a form table to a page with php. This consists of an entry number (auto_increment), a reference number, text, and 3 buttons for different types of users. Its akin to a voting system of sorts you might say. If a user agrees with something, they click a certain button. This increases a counter beside each button. Avoiding double counting, once a user clicks a button, only one submission counts. When the user clicks their button, I check which button was clicked using isset(), that determines the user type, I then check if the user has clicked previously, if yes, do nothing, if no, write the users name to a text file. As I mentioned beside each button is a link to the text file showing the number of users name's in the file like this <a href='Filename.txt'>5</a>, showing 5 names in the file. Clicking on the link will open the text file with the names. I have a table for each user type into which I enter the line number (auto_increment) and the users name. I then query the table, write to the txt file and update the counter on the page. So I need to submit the line number and user type. The button name is the usertype and I want to pass the line number via the onclick function. Hope that wasn't to big a mouthful!
  10. Does $_GET['cell1'] access $cell1['value'] submitted via the submit button?
  11. I have a button that increases a counter (which also a link to a file) beside it. echo "<tr>"; echo "<td name='".$cell1['value']."'>".$cell1['value']."</td><td name='".$cell2['value']."'><a href='file.php'>".$counter."</a><input type='button' name='buttonName' onclick='submit('.$cell1['value'].');'></td> <td name='".$cell2['value']."'><a href='file.php'>".$counter."</a><input type='button' name='buttonName' onclick='submit('.$cell1['value'].');'></td>"; echo "</tr>"; When one of the buttons is clicked I want to pass cell1value to the processing script. Is this the correct way to do it? And how do I access $cell1['value'] after submission?
  12. Just needed an additional table outside the outer while loop.
  13. I don't know if you have tested it or not, but all the files have their own table except for table1. Even though the data seek is set to 0 and I start the table immediately after the first while. I put a border on the table just to make sure. while($rows = mysql_fetch_array($Files)) { print "<table border='1'>"; $current_file = $rows['File']; mysql_data_seek($Amendments, 0); while ($changes = mysql_fetch_array($Amendments)) { if ($changes['File'] == $current_file) { echo "<tr><td>$changes['File'] . "</td><td>" . $changes['Text'] . "</td></tr>"; } } print "</table>"; }
  14. thanks btherl, got it working. Cheers.
  15. Trying to implement mysql_data_seek() but keep getting an infinite loop. Not entirely sure I'm implementing it correctly mind u. $row = array(); while($rows = mysql_fetch_array($Files)) { $row[] = $rows; for($x=0; $x<mysql_num_rows($Amendments); $x++) { if(mysql_data_seek($Amendments, $x)) { while($changes = mysql_fetch_array($Amendments)) { for($i=0; $i<count($row); $i++) { if($rows['File'] = $row[$i]) { echo $changes['Reference'] . "</td><td>" . $changes['Text']; } } } } } }
  16. I got it printing both the file name and text, but its all in the one table. I want to compare the file name in the first (outer) while loop to the file name in the second (inner) while loop and create a new table when the file name changes, but not having any luck figuring out how. while($row = mysql_fetch_array($Files)) { echo "<table border='1'>"; while($changes = mysql_fetch_array($Amendments)) { echo "<tr><td>" . $changes['Reference'] . "</td><td>" . $changes['Text']; } echo "</table>"; }
  17. Nearly there if think. I want to put the changes to each file into a seperate table, a table for each file. I have this: $AmendmentsQuery = "select File, Text from Changes group by File order by File"; $Amendments= mysql_query($AmendmentsQuery); $FilesQuery = "select distinct File from Changes order by File ASC"; $Files= mysql_query($FilesQuery); $row = array(); while($rows = mysql_fetch_array($Files)) { $row[] = $rows; while($changes = mysql_fetch_array($Amendments)) { for($i=0; $i<count($row); $i++) { if($rows['File'] = $row[$i]) { echo $changes['Reference'] . "</td><td>" . $changes['Text']; } } } } Instead of printing the file name it prints array, it prints the text . If I use this while($refs = mysql_fetch_array($Reference)) { $row[] = $rows; while($changes = mysql_fetch_array($Amendments)) { echo $changes['Reference'] . "</td><td>" . $changes['Text']; } } It prints both filename and text. Can anyone explain why the code above won't print the file name?
  18. I used a for loop on $row, but all I got was ArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArray How do I show the filenames?
  19. I have 5 entries in a table $sql = "select count(distinct columnName) from table"; $result = mysql_result($sql); $count = mysql_fetch_array($result); echo $count[0]; The output is 5 as expected. $sql = "select distinct columnName from table"; $result = mysql_result($sql); $count = mysql_fetch_array($result); echo $count[0]; the ouput is the first file name as expected, however echo $count[1]; gives undefined offset 1, which does not make any sense. Can anyone explain why the offset 1 is undefined if the count is 5?
  20. rpjd

    sort trigger

    I thought a table could be sorted after an insert using a trigger. A table like this (unsorted) File1 text changed File3 text changed File4 text changed File1 text changed File2 text changed File5 text changed File2 text changed File3 text changed I want to display grouped by and ordered by File like so in tables Table1 File1 text changed File1 text changed Table2 File2 text changed File2 text changed Table3 File3 text changed File3 text changed Table4 File4 text changed Table5 File5 text changed trying to figure out what queries I need to do this besides select (*) from table group by File order by File and how to nest them. Other queries in conjunction I had in mind were select count(distinct File) from table and select count(changes) from table group by File order by File When printing the result of the first query how to use either or both of the other query results? Any help greatly appreciated.
  21. I want to create a sort trigger, group by and order by on a table after insert. Should the trigger be of this nature create trigger triggername after insert on tablename for each row begin insert into table (column1, column2 ) values ( value1, value2) group by column1 order by column1 end;
  22. If $result contains the result of mysql_query, a select count distinct query, how do I access the count? I've tried $result[0] to no avail and $result only returns the resource #.
  23. To complicate things ever so slightly, when(if) I do get the javascript to run, as I said previously, the number of rows depends on the size of a variable array in $_POST so I need to convert the php array, say $var into a javascript array, iterate through it to insert the POST values into the new rows being created. What I'm thinking is process the submission externally from the webpage, re-direct to the webpage, call the javascipt using onload, convert the processed $_POST elements to javascript variables, then create rows using a for loop iterator. Is this viable? If not, what would be a practical approach?
  24. Does the javascript function to add rows to html tables on a page have to be called from the actual page (even if its using php) or can it be called from an external php file that proceses the form?
  25. The form on page 2 is created when the form on page 1 is submitted, theres no actual html code as such on page 2, and page 2 cannot be accessed unless the user is logged in and submits data from page 1. The form on page 2 is of this nature. <div> <form method='post' action='file.php'> <table> <tr><td>$Ref</td><td>$Text</td></tr> <tr><td></td><td><textarea name='text[]'></textarea></td></tr> <tr><td colspan='2'><input type='submit' value='Submit'></td></tr> </table> </form> </div> The form code on page 2 is written by php when page 1 is submitted. So when the form on page 2 is processed, I need to call a javascript function to add one or more new rows to html tables on page 3. How that is done is my question?
×
×
  • 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.