Web Analytics Made Easy -
StatCounter php sql help unable to display all records??? - CodingForum

Announcement

Collapse
No announcement yet.

php sql help unable to display all records???

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • php sql help unable to display all records???

    Hi All,

    i am having trouble with the following code, it gets the correct number of rows but when it comes to displaying the $title i am getting a few characters show only depending on the number of rows, so for example i may get echo'd on screen "po" instead of poker face?

    not sure how to get all the records to display instead of the first one cut down lol

    please help!!!

    PHP Code:
    $sql "SELECT *
            FROM product_database
            WHERE productTitle REGEXP '
    $test'";
    $query mysql_query($sql);
    $row mysql_fetch_array($query);
    $num_rows mysql_num_rows($query);
    $title $row['productTitle'];
    if (
    $num_rows == 0){
    echo 
    "No Results Please Go Back And Try Again";
    }
    else {
    print 
    $num_rows;
    for (
    $i 0$i $num_rows$i++){
    echo 
    $title[$i];
    }

    any ideas
    many thanks
    Luke

  • #2
    PHP Code:
    $sql "SELECT *
            FROM product_database
            WHERE productTitle REGEXP '
    $test'";
    $query mysql_query($sql);
    $num_rows mysql_num_rows($query);
    if (
    $num_rows == 0){
    echo 
    "No Results Please Go Back And Try Again";
    }
    else 
    {
       while (
    $row mysql_fetch_array($query))
       {
          echo 
    $row['productTitle'] . '<br>';
       }

    John

    Comment


    • #3
      cheers mate you "just" beat me to it lol

      thank you!!!

      Comment


      • #4
        ok how do i change this line to allow it to work?

        ive tried adding /or\ before the ' but it didnt work

        PHP Code:
        echo "<img src='$row['logo']' />"
        ive also tried this
        PHP Code:
        print "<img src='".$row['logo']."' />"
        but its not showing any errors or any images???

        any ideas
        Luke
        Last edited by LJackson; May 20, 2009, 11:43 AM.

        Comment


        • #5
          PHP Code:
          print '<img src="' $row['logo'] .'" />'
          Dave .... HostMonster for all of your hosting needs

          Comment


          • #6
            thanks mate,

            and what about this one
            PHP Code:
            print "$category"."_stores.php" 
            $category = electronics
            so i would want it to print electronics_stores.php

            any ideas
            cheers

            Comment


            • #7
              PHP Code:
              print $category '_stores.php' 
              Dave .... HostMonster for all of your hosting needs

              Comment


              • #8
                thanks mate really appreciate all your help

                cheers
                Luke

                Comment

                Working...
                X