[PHP] Display just 1 record in a query
I did a query... then I display records like: Q: but how I i just display a particular record with out the do / while loop? like just the 2nd record only: i tried but this makes an error or $row_cur('tid',2) --- hmmm what's the syntax? Thanks, deal...@gmail.com [db-10] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Display just 1 record in a query
On Jan 12, 2010, at 1:57 PM, Ashley Sheridan wrote: Depends on how you're creating running the query. You could do something like: echo mysql_result($result, 1, 'fieldname'); Where $result is your result object and 1 is a 0 indexed array, so would be the second result. Thanks Ryan, Ashley & Kim for the good techniques... - in my case I was trying to pull a random record from a query of Table1 - then do a 2nd query from 1st so mysql_result worked fine for my needs like: ... do query 1... 'cur' - SELECT id FROM myTable1 $ran = rand(0, $totalRows_cur - 1); // pick random rec row within total count $pick1 = mysql_result($cur, $ran); // get the ID from the choice - (like id=252) ... do query 2 // where relatedID = $pick1 of myTable2 cool - THANKS ALL! Thanks, deal...@gmail.com [db-10] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP & MS Sequel Server
On Jan 17, 2010, at 11:06 AM, Ashley Sheridan wrote: On Sun, 2010-01-17 at 10:47 -0800, dealtek wrote: http://www.aspfree.com/c/a/MS-SQL-Server/Using-PHP-with-MS-SQL- Server/ This article seems to sate that PHP can interface with MS Sequel Server ? If so, is it about the same level of complexity as working with PHP & MySQL? If one was to choose php & one DB over the other in a general comparison (not cost): any preferences? You can use PHP and MSSQL quite happily together on either Apache or IIS. I've found a few disadvantages to MSSQL other than the cost factor though: MySQL is faster in the main for the sorts of things I've thrown at it I've not found a phpMyAdmin equivalent, which means you'd have to use the non-web interface that MS gives you unless you want to open all sorts of ports to connect remotely Depending on the version you may be missing out on certain features. I had to use a version of MSSQL once that had no LIMIT capabilities, only TOP, which made things a lot more difficult PHP doesn't have a mysql_real_escape_string equivalent for MSSQL, which is used to sanitise data for insertion based on the character set being used. MSSQL doesn't allow you to use different database engines for different tables, it only has the JET engine as far as I know, so you wouldn't be able to optimise on a table-by-table basis by using different storage engines. Thanks so much Ashley for the clear - quick response!!! The project in question is a pre existing site in .asp and MS SQL Server . The owner was inquiring as to adding additional modules (and small satellite websites) - most of which will not intersect with .asp but might use the MS SQL Server database... I suggested they find an .asp programmer but they might want PHP ... Thanks, deal...@gmail.com [db-10] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Creating an Entire .html page with PHP
Hi Folks, I would like to create an entire .html page gathered from database content mixed with html etc. and be able to save the page... like: --- save all this pre made content as .html page ... stuff ... stuff ... stuff with database query results... ... stuff Q: Is there a function that might help with saving the whole content as .html page? Thanks, deal...@gmail.com [db-10] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating an Entire .html page with PHP
On Jan 25, 2010, at 4:59 PM, Ashley Sheridan wrote: $fh = fopen("page.html","w"); fwrite($fh, $htmlcode); Thanks so much Ashley and ALL, this looks like it will work fine. BTW: Sorry if I didn't make myself clear - I just wanted to grab some data like a person from a contacts file and be able to save a static .html web page with their data - etc. ... this little test seems to work I added fclose($fh); at the end (correct?) - - - - - - $htmlcode = 'Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1- transitional.dtd"> http://www.w3.org/1999/xhtml";> Untitled Document this is a test'.$addthis.''.$row_get['FirstName'].' '.$row_get['LastName'].' this is a test 2 '; fwrite($fh, $htmlcode); fclose($fh); ?> Thanks, deal...@gmail.com [db-10] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating an Entire .html page with PHP
On Jan 25, 2010, at 6:23 PM, Shawn McKenzie wrote: file_put_contents() is s much easier. Thanks Shawn I'll check that out ... - I see it says : This function is identical to calling fopen(), fwrite() and fclose() successively to write data to a file. my newbie brain likes that! Thanks, deal...@gmail.com [db-10] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie sequel question: how do we search for multiple things on 1 field like:
Thanks Daniel and Rick! I will start using this... We begin by asking on the right list (my...@lists.mysql.com, CC'd by courtesy). Thanks, Dave deal...@gmail.com [db-10] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php