Jump to content

wobuck

Members
  • Posts

    19
  • Joined

  • Last visited

Everything posted by wobuck

  1. I need to dynamically build a javascript to show images using greybox. I have looked through greybox user groups and have found some answers close to my need but I am unsure of the actual coding as I am unfamiliar with javascript. I want to use php to insert mysql data from a file of image information so as to generate the javascript something like the following but am unsure how to do it: I need to understand the code to dynamically generate the multiple lines into the javascript below thus: <script> var image_set = [ {'caption': '< ?php echo $desc ?>', '< ?php echo $url ?>': '< ?php echo $image ?>'}, {'caption': '< ?php echo $desc ?>', '< ?php echo $url ?>': '< ?php echo $image ?>'}, {'caption': '< ?php echo $desc ?>', '< ?php echo $url ?>': '< ?php echo $image ?>'}, {etc, etc} ]; </script> Any help would be appreciated.
  2. Using BlueSkyIS's response set me on the right 'path' to resolving the issue: Used this to find paths: print realpath(basename(getenv("SCRIPT_NAME"))); print("<br>"); print realpath(basename(getenv("DOCUMENT ROOT"))); print("<br>"); Resulting in working out this code which works: $docRoot = getenv("DOCUMENT_ROOT"); include $docRoot."/folder/constantsdata.inc.php"; Many Thanks to BlueSkyis!
  3. Your Question "What's wrong with include('inc.php'); ?" include("constantsdata.inc.php"); this works ok but the file,constantsdata.inc.php, has to be in the same directory as the php file calling the include which means I have to maintain every copy of this file in all directories I am using it. I have tried variants like: include("http://localhost/folder/constantsdata.inc.php"); include('http://localhost/folder/constantsdata.inc.php'); to call the file from another directory e.g. folder but it does not work?
  4. I am trying to include a inc.php file within a normal .php file from a single directory as I am using it in several directories but cannot get it to work and have tried many different techniques. Any ideas on the coding that would work would be appreciated? Alternatively, I would be happy to set the constants in a mysql db but am unsure how I would unpack/read it so as to get it in the php program as code i.e. mysql db field 1 field 2 name $name Program <?php $name; ?>
  5. Great stuff! All now working many thanks for your help
  6. Many Thanks Starting to code now and will post when successful!
  7. Yes, I have found this type of solution but I am unable to put it in the php code without getting errors - my coding knowledge of mixing javascript and php is limited. Can you help?
  8. I have tried various different methods to put a single field in to enable check/uncheck all items but cannot get any to work. It would be really helpful if someone can supply the correct coding? In anticipation Thanks My code: <?php $rowa=0; print("<br></br>"); mysql_connect($host,$username,$password); //(host, username, password) mysql_select_db($database) or die("Unable to select database"); //select which database we're using $query = "SELECT id, forename, surname, emailaddress FROM master ORDER by surname,forename"; $result = mysql_query($query); while($row = mysql_fetch_row($result)) { $id=$row[0]; $forename=$row[1]; $surname=$row[2]; $email=$row[3]; $member="$forename $surname"; print("<table style=\"BORDER-COLLAPSE: collapse\" border=\"1\">"); print("<tr><form id=\"checkboxform\" action=\"email.php\" method=\"GET\">"); print("<td width=\"20px\" bgColor=\"#eaf1f7\"><input type=\"checkbox\" name=\"checkbox[$rowa]\" value=\"$id\" checked=\"checked \"></td>"); print("<input type=\"hidden\" style=\"width: 60px\" name=\"id[$rowa]\" value=\"$id\"></td>"); print("<input type=\"hidden\" style=\"width: 60px\" name=\"forename[$rowa]\" value=\"$forename\"></td>"); print("<input type=\"hidden\" style=\"width: 60px\" name=\"surname[$rowa]\" value=\"$surname\">"); print("<input type=\"hidden\" style=\"width: 250px\" name=\"email[$rowa]\" value=\"$email\">"); print("<input type=\"hidden\" style=\"width: 80px\" name=\"active[$rowa]\" value=\"$active\">"); print("<td width=\"135px\" bgColor=\"#eaf1f7\"><font face=\"Arial\" size=\"2\"><div ALIGN=\"LEFT\">$member</div></td>"); print("<td width=\"250px\" bgColor=\"#eaf1f7\"><font face=\"Arial\" size=\"2\"><div ALIGN=\"LEFT\">$email</div></td>"); print("</table>"); $rowa++; } print("<td><br></td></tr>"); print("<tr><td width=\"105px\" bgColor=\"#eaf1f7\"><font size=\"2\" title=\"$editdeletetxt\"> <input value=\"Send Email\" type= \"Submit\"> To All Ticked Above</td><br>"); print("<br></tr>"); ?>
  9. Problem Solved! Here is the code that works: <HTML> <HEAD> <TITLE>JavaScript Toolbox - Calendar Popup To Select Date</TITLE> <SCRIPT LANGUAGE="JavaScript" SRC="CalendarPopup.js"></SCRIPT> <SCRIPT LANGUAGE="JavaScript" ID="js13"> var cal13 = new CalendarPopup(); </SCRIPT> </HEAD> <BODY> <FORM NAME="example" method="get" action="nextfile.php"> Start date and end date, with end date defaulting to same date as start date<BR> Start: <INPUT TYPE="text" NAME="date13" VALUE="" SIZE=25> <A HREF="#" onClick="cal13.select(document.forms[0].date13,'anchor13','dd/MM/yyyy'); return false;" TITLE="cal13.select(document.forms[0].date13,'anchor13','MM/dd/yyyy'); return false;" NAME="anchor13" ID="anchor13">select</A> End: <INPUT TYPE="text" NAME="date14" VALUE="" SIZE=25> <A HREF="#" onClick="cal13.select(document.forms[0].date14,'anchor14','dd/MM/yyyy',(document.forms[0].date14.value=='')?document.forms[0].date13.value:null); return false;" TITLE="cal13.select(document.forms[0].date14,'anchor14','MM/dd/yyyy',(document.forms[0].date14.value=='')?document.forms[0].date13.value:null); return false;" NAME="anchor14" ID="anchor14">select</A> <input type="submit" name="submit" value="SUBMIT" class="red"> </FORM> </BODY> </HTML>
  10. I have some code below but am unable to get the dates (date13 & date14) passed to a php file. <HTML> <HEAD> <TITLE>JavaScript Toolbox - Calendar Popup To Select Date</TITLE> <SCRIPT LANGUAGE="JavaScript" SRC="CalendarPopup.js"></SCRIPT> <SCRIPT LANGUAGE="JavaScript" ID="js13"> var cal13 = new CalendarPopup(); </SCRIPT> </HEAD> <BODY> <FORM NAME="example"> Start date and end date, with end date defaulting to same date as start date<BR> Start: <INPUT TYPE="text" NAME="date13" VALUE="" SIZE=25> <A HREF="#" onClick="cal13.select(document.forms[0].date13,'anchor13','dd/MM/yyyy'); return false;" TITLE="cal13.select(document.forms[0].date13,'anchor13','MM/dd/yyyy'); return false;" NAME="anchor13" ID="anchor13">select</A> End: <INPUT TYPE="text" NAME="date14" VALUE="" SIZE=25> <A HREF="#" onClick="cal13.select(document.forms[0].date14,'anchor14','dd/MM/yyyy',(document.forms[0].date14.value=='')?document.forms[0].date13.value:null); return false;" TITLE="cal13.select(document.forms[0].date14,'anchor14','MM/dd/yyyy',(document.forms[0].date14.value=='')?document.forms[0].date13.value:null); return false;" NAME="anchor14" ID="anchor14">select</A> </FORM> <form method="get" action="nextfile.php"> <input type="hidden" name="date13" size="12" value="date13""> <input type="hidden" name="date14" size="12" value="date14"> <input name="Submit1" type="submit" value="submit"></form> </BODY> </HTML> Any help appreciated
  11. Too many formatting issues for lots of other lines led me to this! Many thanks
  12. The following html code works in IE & Firefox but the PHP code only works in IE Any help appreciated. <html> <body> <select size="1" name="place"> <option value=" ">Select</option> <option value="1st">1st</option> <option value="2nd">2nd</option> <option value="3rd">3rd</option> <option value="4th">4th</option> <option value="5th">5th</option> </select> </body> </html> <?php print("<td><select size=\"60px\" name=\"place\">"); print("<option value=\" \">Select</option>"); print("<option value=\"1st\">1st</option>"); print("<option value=\"2nd\">2nd</option>"); print("<option value=\"3rd\">3rd</option>"); print("<option value=\"4th\">4th</option>"); print("<option value=\"5th\">5th</option>"); print("</select></td>"); ?>
  13. Problem resolved!! I was using $row which was also being used to extract the database records. Once I declared another variable data started being passed correctly after using a foreach statement in the receiving php program.
  14. I extracted the raw code for the 1st line: <input type="text" style="width: 60px" name="book[Array?]"> <INPUT TYPE="hidden" name="row_count" value="Array?"></INPUT>
  15. Apologies, I have not explained my issue very well. I am using the 'print' command within a php form to display a number of lines from a database so that I can then enter more data against the displayed lines as <Input type=text> The command lines looks like this: print("<form id=\bookform\" action=\"book.php\" method=\"get\">"); while($row = mysql_fetch_row($result)) { print("<td><input type=\"text\" style=\"width: 60px\" name=\"book[$row?]\"></td>"); print("<td><INPUT TYPE=\"hidden\" name=\"row_count\" value=\"$row?"></INPUT></td>"); } print("<td><input value=\"UPDATE BOOKS\" type=\"Submit\"></td></tr>"); I then try to retrieve the entered data from the form in the book.php program thus: $book = $_GET[book']; $row_count = $_GET['row_count']; $row=0; while ($row<$row_count) { echo('<tr><td><font face="Arial" size="2"><strong>*'.book[$row_count].'*</strong></font></td></tr>'); $row++; } Nothing appears to be retrieved to echo? I have tried both post and get
  16. I generate php form lines from a database but cannot work out how to recover the text fields for lines 1, 2 & 4 using get or post - can anyone help? The url string below(get to see what is happening) contains titles BF and SG in lines 1 and 2 for the field name 'book' and then TG for line 4 but no title for line 3: http://localhost/test/test.php ?book%5BArray%3F%5D=BF&row_count=Array%3F &book%5BArray%3F%5D=SG&row_count=Array%3F &book%5BArray%3F%5D=&row_count=Array%3F &book%5BArray%3F%5D=TG&row_count=Array%3F
  17. Apologies for delay in response - yes you are correct the line is not needed. Problem now solved - it was the sparsing bit where I was looking for ; which was the wrong character should have been a comma! Many thanks!
  18. I am very new to php and suspect I have made a coding error. 1) I created an HTML form: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Serial Number</title> </head> <body> <form method="GET" action="prop2.php"> <!--&beds=--> Serial<br /><br /> <select class="formboxsize" size="1" name="serial"> <option value="1" selected>1</option> <option value="2">2</option> <option value="3">3</option> </select><br /><br /> <input type="submit" name="submit" value="Submit"></div> </form> </body> </html> 2) Then I created a PHP file; <?php $file = "xfile.csv"; $serial = $_POST['serial']; if ( !empty ( $_GET['serial'] ) ) { $serial = $_GET['serial']; $file_content = file_get_contents ( $file ); $file_arr = preg_split ( '/\n/' , $file_content ); $found = false; foreach ( $file_arr as $item ) { $data = explode ( ';' , $item ); if ( $data[0] === $serial ) { $found = true; $date = $data[1]; } } if ( $found ) { print "Date: " . $date; } else { print "Not found"; } } ?> 3) The xfile.csv file contains: serial date Warranty 1 01/01/2008 01/01/2009 2 24/02/2008 23/01/2009 3 10/10/2008 09/09/2009 4) When I run the form it returns "Not found" If I change the php file command $found = false; to true it displays the word Date: as expected, but no data from the file? Any help would be greatly appreciated? Wobuck
×
×
  • 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.