Jump to content

rpjd

Members
  • Posts

    66
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

rpjd's Achievements

Member

Member (2/5)

0

Reputation

  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']; } } } } } }
×
×
  • 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.