Jump to content

kobanrichard

New Members
  • Posts

    2
  • Joined

  • Last visited

kobanrichard's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. $page['content'] is an array element which comes from the MySQL database with the mysqli_fetch_assoc() function. This array element contains this string: <h1>Title of the page</h1> {gallery:10} <p>Other informations...</p> In the end, I want to display images on a page, depending on the number between the curly brackets, like this: <h1>Title of the page</h1> <img src="admin/uploaded/someimg.jpg" /> <img src="admin/uploaded/someotherimg.jpg" /> <img src="admin/uploaded/anotherimg.jpg" /> <p>Other informations...</p>
  2. I have an array element that contains a subpage's content: $page['content'] I want to do some MySQL query, if the variable's content contains this pattern: {gallery:somerandomIDnumber} The problem is, I don't want to lose the other stuff, and it's also important that the query should run where the pattern belongs. For example, this is the $page['content'] content: <h1>Title of the page</h1> {gallery:10} <p>Other informations...</p> I tried this with preg_match function, but unfortunately I can't figure it out, how I can save the other content around my {gallery:10} pattern. // Gallery include by ID preg_match('~\{gallery\:[0-9]{1,5}\}~', $page['content'], $matches); foreach($matches[0] as $value) { $int = filter_var($value, FILTER_SANITIZE_NUMBER_INT); $query = 'SELECT * '; $query .= 'FROM gallery_images '; $query .= 'WHERE gid = '.$int; $gallery = ms_query($query); //ms_query is a function I wrote myself. Unlike mysqli_query function this function doesn't require the connection parameter every single time I call it, only the query itself while($gimage = mysqli_fetch_assoc($gallery)) { echo '<img src="admin/uploaded/'.$gimage['imagepath'].'" width ="100">'; } } Summarazing, in this situation, I want to echo 1. the title of the page 2. some imagepath from my database 3. other informations Thanks in return for Your help!
×
×
  • 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.