Jump to content

programguru

Members
  • Posts

    133
  • Joined

  • Last visited

    Never

Posts posted by programguru

  1. o3d,

    Thanks. Worked like a charm. I guess I have a lot to learn with this specific type of loop, because I can't get this to work with my table output structure now. It's only echoing the key value pair from the form:

     

    $while_full_result='';

    while(list($key, $val) = each($_POST)) {

    $while_full_result  = "<table border=\"1\">";

    $while_full_result .= "<tr><td>$key</td><td>$val</td></tr>";

    $while_full_result .= "</table>";

    }

    $message = $while_full_result;

     

    I actually had luck echoing it to the page, but I could not get it to print in the email?????

     

    $while_full_result='';

    while(list($key, $val) = each($_POST)) {

    $while_full_result .= "<tr><td>$key</td><td>$val</td></tr>";

    }

    $message = "<table>$while_full_result</table>";

    echo $message;

     

    // Mail it

    mail($to, $subject, $message, $headers);

  2. o3d,

    Thanks. Worked like a charm. I guess I have a lot to learn with this specific type of loop, because I can't get this to work with my table output structure now. It's only echoing the key value pair from the form:

     

    $while_full_result='';

    while(list($key, $val) = each($_POST)) {

    $while_full_result  = "<table border=\"1\">";

    $while_full_result .= "<tr><td>$key</td><td>$val</td></tr>";

    $while_full_result .= "</table>";

    }

    $message = $while_full_result;

  3. I am simply trying to store the full results of my while loop in a variable to store into a variable for a mail() script I am writing.

     

    while(list($key, $val) = each($_POST)) {
    	"<strong>$key</strong> => $val<br />";
    }
    
    $message = $while_full_result;
    echo $message;

     

    This should echo the same output as the while loop natively does.

     

    But I cannot get this to work properly.

     

    Thanks for any advice.

     

     

  4. have a situation where I have a specific website I am working on.

     

    Select the category, sub-category, then product.

     

    The product page loads very slowly for some reason. Even if there are not images on the page its just dragging.

     

    No other sites on the same server are having this issue.

     

    My supsicions are:

     

    --MySQL connection speed

    --MySQL data loading

     

    There are multiple form fields being populated.

     

    Does anyone know of a script for the actual page which I can test the speed of the MySQL query when the page loads?

     

     

  5. Can anyone see an issue with this causing the parse error. Am I losing my mind!!

     

    Parse error: syntax error, unexpected ',' in D:\mydirectory\product.php on line 5

     

    <?php
      class Product extends AppModel
      {
    var $name = 'Product';
    var $belongsTo = array('Dealer' => array('className' => 'Dealer', 'conditions'=>, 'order'=>, 'foreignKey' => 'dealer_id'));
      }
    ?>

     

     

  6. Hmmm... I don't see an out on this, but was wondering if you know of a function or method to do this business:

     

    My script works perfect with the exception of my empty() function, because I see the date() function creates a value regardless if my field $date_start (from my table) is in fact empty.

     

    I'm just trying to echo nothing if the value of $date_start is NULL (blank). Any ideas where to look on this one?

    ....

    $date_start = $row['date_start'];

    $date_end = $row['date_end'];

     

    $date_start_converted = date("M jS, Y", strtotime($date_start));

    $date_end_converted = date("M jS, Y", strtotime($date_end));

     

    if (empty($date_start_converted)) {

    $date_start_converted = "";

    }

     

    ....

     

  7. Hello,

     

    Is it possible to "fetch" variable content details from an external website with php?

     

    For example, if I wanted to create a custom ebay log of my for-sale items with my own custom interface (I know I would probably not be able to alter the data) and on a different domain name.

     

    Is this possible with php? And if so, does anyone know the correct technical term for this and possible an example or tutorial you can link me up to?

     

    Thanks for any advice on this.

  8. does anyone have an idea on selecting random records.. my code is working fine as is.

     

    as you can see my mysql query is limited to 3 WHERE featured=1, but it's possible i will have 20-30 featured records.

     

    i tried variations of php rand() and its family with no luck..

     

    any ideas?

     

     ... $sql = "SELECT id, date_added, date_start, date_end, title, spaw1, featured FROM $table_name WHERE featured=1 ORDER by date_added LIMIT 3";
    
    $result = mysql_query($sql) or die(mysql_error());
    
    while ($row = mysql_fetch_array($result)) {
    		$id = $row['id'];
    		$date_added = $row['date_added'];
    		$date_start = $row['date_start']; ... 

  9. You don't even need that first mysql_fetch_array(). The while loop conditional will retrieve the rows until it has no more to retrieve, then mysql_fetch_array() will return false and terminate the loop.

     

    i see what you mean.. the results are perfect now, but i just need to limit the results to a max of 3 less than or equal to 3... messing around with that now, and more errors :)

     

    if you have any idea on this, please feel free to throw your advice

     

     

  10. You're setting $num to being mysql_num_rows(), so 4. Then you're doing while(4 <= 4) do something then increase $num. This results in 5 <= 4 so it breaks. the easiest method is instead of using mysql_num_rows() just do..

     

    $result = mysql_query($sql) or die(mysql_error());
    // Code removed here
    
    while ($row = mysql_fetch_array($result)) {
             // And here (moved up to the where clause)
             $id = $row['id'];
    

     

    genericnumber1,

    thanks for the insight.. i feel like a moron after 3 hours or trying to figure this out.. 4 <= 4 man what was I thinking!

    still learning...

     

    im going to test it in the am, but was this is what you mean?

     

    ... $result = mysql_query($sql) or die(mysql_error());

    $row = mysql_fetch_array($result);

     

    while ($row = mysql_fetch_array($result)) {

            $id = $row['id'];  ...

     

  11. i cannot get my results to be 4 or less, and i don't know why my script will not do this! all i can get it to do is print one record when it should be printing up to 4 that meet my criteria as you can see in my mysql query.

     

    // test featured only list 
    $table_name = "special";
    $bd_string_featured = "<table>
    <tr>
    <th>Date Added</th>
    <th>Date Start</th>
    <th>Date End</th>
    <th>Title</th>
    <th>View</th>
    <th>Edit</th>
    <th>Delete</th>
    <th>Featured</th>
    </tr>
    ";
    $sql = "SELECT id, date_added, date_start, date_end, title, spaw1, featured FROM $table_name WHERE featured=1 ORDER by date_added";
    
    $result = mysql_query($sql) or die(mysql_error());
    $num = mysql_num_rows($result);
    echo $num;
    
    while ($num <= 4) { 
    		$row = mysql_fetch_array($result);
    		$id = $row['id'];
    		$date_added = $row['date_added'];
    		$date_start = $row['date_start'];
    		$date_end = $row['date_end'];
    		$title = $row['title'];
    		$featured = $row['featured'];
             	$bd_string_featured .= '<tr>
    		<td> ' . $date_added .' </td>
    		<td> ' . $date_start .' </td>
    		<td> ' . $date_end .' </td>
    		<td><a href="app_view_special.php?id=' . $id . '">' . $title . '</a></td>
    		<td><a href="app_view_special.php?id=' . $id . '">View</a></td>
    		<td><a href="review_edit_special.php?id=' . $id . '">Edit</a></td>
    		<td><a href="javascript:deleteConfirmation(\'app_delete_special.php?id=' . $id . '\')">Delete</a></td>
    		<td>' . $featured . '</td></tr>';
    		$bd_string_featured .= "</table>";
    		$num++;
             }
    ?>

  12. I should have mentioned I have a way to do this by creating arrays for each "Browse" option, but what I really need to be able to do is:

     

    Let's say I have already uploaded 5 images, and I want to add another, I should have a link that says "Add Another Image", and that would create a new Browse box to submit a new image.

     

    SO I am beginning to think some type of while array will be the only way to do this, and will also need some javascript to control the dom Browse div box...

     

    Still seeking answers...

  13. So far I have gotten my script to the point of uploading 1 image.

     

    I would like to extend this per transaction to:

     

    1) Upload unlimited images (disregarding server limits).

     

    2) Manage the uploaded images (edit/delete).

     

    3) Position the images in linear format for UI display.

     

    Does anyone have a recommendation on a tutorial, or other documents that cover this specifically? Or your own ideas on where to start with this?

     

  14. FYI if you want the answer, for what was going on, your test script worked exactly as expected.  PHP is somewhat odd, in that what the global keyword does is say -- reference the "global variable of this name" in the function rather than make a new local variable.  So you set the variable in the global scope at the top, in in the one function you declare the global and echo it.  It displays of course.  In the other you don't and you get no echo. 

     

    This is exactly what global does, and why it's a bad idea and a mess that produces spaghetti.  Once you start using it, you might as well have one big gigantic script with no functions at all.

     

    I hate globasl! But I added a & (reference) to the front of that the var that was not outputting and now it is:

     

    function globalEcho() {

       echo "&$table_name";

    }

     

    Globals are bad. I don't think you get it.

     

    i don't get a lot of things

  15. thorpe,

     

    that did work!

     

    and you are right. it does not make much sense as i am normalizing my db data.

     

    so maybe i went all this way for really no good reason!

     

    however, i just realized i can just define all my tables in the costants, so i can still keep it all in one place.

     

    im not sure how this applies to viewSpecialsUi():

     

    "Though really, functions are most useful when they simply return result and not echo them."

     

    do you mean the function output should be returned as opposed to echoed like: echo "<p>There are no records to display.</p>";???

     

     

×
×
  • 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.