Jump to content

JonnoTheDev

Staff Alumni
  • Posts

    3,584
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by JonnoTheDev

  1. Expand on something like the following: <?php $images = array(1,2,3,4,5); foreach($images as $imageNum) { print "Image ".$imageNum." <input type=file name='img".$imageNum."' id='img".$imageNum."' disabled><input type=hidden name=blank".$imageNum." value='replace'><br />"; } ?>
  2. thorpe's suggestion will work using wget as long as the site giving you the db dump doesnt require any authentication or a form submitting to retrieve the file. Then you would need CURL to do this.
  3. When you say dump their database - are they giving you the sql or are they giving you the database in CSV format. If they are giving you the sql then this is easy. Use CURL to download the sql.tar.gz file. Extract the tar.gz file: tar -xvzf sql.tar.gz Use mysql to restore the file: mysql -u -p databaseName < pathtosql So your program to run from a cron can be a simple file that contains: php /home/user/getDBFile.php tar -xvzf sql.tar.gz mysql -u -p databaseName < pathtosql We save this file as dbupdate Then in your crontab: * * * * * /path/dbupdate
  4. What the posts above are stating is correct but there is a hell of a lot more needed (if I were making this) to consider. The first is a proper error routine. If an error is detected do you stop at that point or continue inserting the data? Each field must be validated to ensure that the correct data types are inserted into the correct mysql fields. So if the database is expecting an email address to go into an email field then the xls value must be an email address and not say a numeric value or non-email address value. As in coolphpdude's post you may be better using pipe delimiters rather than csv values as text often contains commas and can cause your data to be improperly separated.
  5. This is known as mod_rewrite and rewrites are defined in your httpd.conf file or an .htaccess document. You will need to do some research on this subject.
  6. Using Javascript
  7. $string = "This text will become to this "; $string = preg_replace('/ {2,}/', ' ', $string); print $string;
  8. Package http://pear.php.net/package/Mail_Mime
  9. You cannot include attachments using the mail() function. Use PEAR::Mail_Mime You will have to add these packages. Then you can use: $mail = new Mail_mime(); $mail->addAttachment("file.jpg", "text");
  10. You will not get this data from 1 query. You will have to start with the category query then select the sub-categories from the category ID within a loop from the category query
  11. functions that accept arrays will cause an error if the value is not an array so it is always best to define the variable as an array. $data = array();
  12. Then the value isnt being passed to or read by the page page correctly. Is it a GET or POST value? Have you echoed it to the screen to test it exists?
  13. Is $numseats from a GET or POST request as you should use $_GET['numseats'] or $_POST['numseats'] Also using the empty() function is not the best approach. If you are expecting the nomber of seats to be a numeric value: $numseats = $_GET['numseats']; if(!is_numeric($numseats)) { // back to the form header("Location:formpage.php"); exit; } else { //process $numseats }
  14. I dont think that opening an existing PDF and writing data to it can be done although I have not looked at the FPDF library. I have used the PDF libraries in the ZEND framework (think its ZEND_pdf) to create a pdf document using user inputted data and using x,y coords to place the data which worked well, especially for creating hings like invoices on ecommerce apps.
  15. OK. You need to learn a relational database if you want dynamic capabilities in your website.
  16. Wow. How did you create your database tables? Are you using phpmyadmin or a similar web based program? If so, put your SQL into the query window to test. Using MYSQL on the command line: If using linux then login to the mysql server via SSH (if you are allowed to do this, maybe you are on a shared server, dunno). If Windows then dont know because Windows is a crap platform (my god that statements gonna get some feedback)
  17. No. 1 table. When you stated: What was the id supposed to reference in ?id=x In most cases this is the primary key value for the database table you are querying
  18. You really need to test your queries through mysql before putting them into your site to make sure the data you expect gets returned
  19. OK, Heres your code $issues_query = "SELECT * FROM issues_booked WHERE ib_booking_form_number = $bf_id"; $issues_result = mysql_query ($issues_query); $data = array(); while ($issues_row = mysql_fetch_array ($issues_result, MYSQL_ASSOC)) { $data[] = $issues_row['ib_issue_number']; } print implode(", ", $data);
  20. No, a static page is just HTML - no PHP and not for your application. Its a template to show what the page will look like after you put your dynamic bits in. Without an example of what the page is supposed to look like its hard to give any suggestions on how to make it work dynamically. So for your users location page you make a users-location.html that is basically displaying the layout or what would be the final output. Then when the code is inserted to make it a dynamic page we end up with a users-location.php file
  21. Dont you want to find the record from the ID? if (isset($_GET['id'])) { //Define the query $query = "SELECT *, DATE_FORMAT(`datecreated`, '%M %e, %Y') as datecreated FROM titlehistory"; Should be if (isset($_GET['id'])) { //Define the query $query = "SELECT *, DATE_FORMAT(`datecreated`, '%M %e, %Y') as datecreated FROM titlehistory WHERE id='".$_GET['id']."'";
  22. This is not a PHP issue. If the URL "http://subdomain.url.com/child.php" is resolving to 2.2.2.2 then this needs to be accessible through the firewall. You may have an internal DNS issue
  23. Store it wherever you like. In text files is more difficult if the title needs to be extracted as a separate piece of data. In mysql you could have a page content table with fields pageId, title, content Then your page title is sent to the template: $smarty->assign('title', $row['title']);
  24. Will get you the numeric value of the radio count: $string = '<p><span style="font-size:0.8em;">songs played:</span> 152</p><p><span style="font-size:0.8em;">radio count:</span> 1</p>'; $string = strip_tags($string); preg_match('/radio count: ([0-9]+)/', $string, $matches); print $matches[1];
×
×
  • 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.