Announcement

Collapse
No announcement yet.

PHP Questions

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

  • Dan615
    replied
    Bah, that's easy Unfortunately, I'm in the midst of doing something else, but I'll get back to you...

    In the mean time, what version of PHP and what version of MySQL are you running?

    Leave a comment:


  • MartynJ
    replied
    Well, thanks guys for all your help. Basically, I am making a site in PHP/MySQL about a tv series, I have an SQL table called episodes, and in each unique ID I have fields for "epTitle", "epReview", "epRating" and "epImage" etc, what I want to be able to do is create a single PHP page that can accept URL parameters from a search form and build up a list of matching results by filling in the search result data into predesigned HTML tags, looping if necessary until all matching results are shown. Help?

    Leave a comment:


  • scoutt
    replied
    good catch dan, but he didn't say he wanted more than 1 image

    and I just threw that up there as I know there is several ways of doing it. that was a piece I had handy

    Leave a comment:


  • Dan615
    replied
    Originally posted by scoutt
    easy. the path that is in the atabase could be something like /images/img.jpg
    PHP Code:
    $sql "SELECT * FROM image_table'"// queries the database for the image paths
     
    $result mysql_query ($sql);

      if (!
    $result) {echo mysql_error();}  // detects to see if thre is an error and then prints it out.
    while ($row mysql_fetch_array($result)) // gets the table row
            
    {
                 
    $path $row["path"];
                 
            }

    echo 
    "<img src=\"$path\" border=0>"
    Since I'm bored, I'm gonna reformat the code the way I like it...I think MY way is more efficient Just kidding

    PHP Code:
    $result mysql_query("select image_path from the_table") or die(mysql_error());    // get the image_path field from the_table (the name of the table)

    while ($image mysql_fetch_array($result)) {
        echo 
    "<img src=\"$image[image_path]\">";    // print the image

    Actually, your code wouldn'r run correctly, the $path variable gets re-assigned every time it loops through the rows...so only one image would get printed, instead of all of them

    I'm not poking fun, just pointing it out

    Leave a comment:


  • MartynJ
    replied
    Thanks mate, I appreciate it. Though, watch this space for any further problems I have.

    Leave a comment:


  • scoutt
    replied
    easy. the path that is in the atabase could be something like /images/img.jpg
    PHP Code:
    $sql "SELECT * FROM image_table'"// queries the database for the image paths
     
    $result mysql_query ($sql);

      if (!
    $result) {echo mysql_error();}  // detects to see if thre is an error and then prints it out.
    while ($row mysql_fetch_array($result)) // gets the table row
            
    {
                 
    $path $row["path"];
                 
            }

    echo 
    "<img src=\"$path\" border=0>"

    Leave a comment:


  • MartynJ
    replied
    Yeah, but thing is, I know heck all about PHP. Can someone please post up how to call a path from a database, then tie it to a variable name, then insert that variable into standard HTML?

    Leave a comment:


  • scoutt
    replied
    then just put the path to the image in the database. and call it like you just suggested.

    Leave a comment:


  • MartynJ
    started a topic PHP Questions

    PHP Questions

    OK, not exactly vBulletin related, but all the actual PHP forums on the net are crap. Basically, I am building a site for someone from scratch, taking the content of their HTML site and entering it into a MySQL database. I have started learning PHP and can connect to the database, read strings from it and dump them onto a page. What I would like to do is say "Query this, and call the result $nameofresult or whatever so that I can go back and make vB style pages with HTML code that references these.
    The biggest problem is that for the database, I have the URL of an image, but want to call that from the database by PHP and call it $image1url or whatever and then get the PHP to drop it into

    < IMG SRC = "$image1url " > etc

    Help, please?
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X