Jump to content

aftab_jii

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

aftab_jii's Achievements

Member

Member (2/5)

0

Reputation

  1. @jcbones so where could i find something to show images that has is_published=1 @teamatomic your idea worked half ways it showed all the images on one page instead of as a sideshow
  2. Hi, I am trying to customize a script that shows random images.. i am obviously doing something wrong because the script does not show any images can someone help me? <?php //this is the file for all the function function getRandomImage($dir,$type='random') { global $errors,$seed; if (is_dir($dir)) { $fd = opendir($dir); $images = array(); while (($part = @readdir($fd)) == true) { if ( @eregi("(gif|jpg|png|jpeg)$",$part) ) { $images[] = $part; } } // adding this in case you want to return the image array if ($type == 'all') return $images; if ($seed !== true) { mt_srand ((double) microtime() * 1000000); $seed = true; } $key = mt_rand (0,sizeof($images)-1); return $dir . $images[$key]; } else { $errors[] = $dir.' is not a directory'; return false; } } $query = "SELECT * FROM images WHERE is_published=1"; $result = mysql_query ($query); // Run the query while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { $image_id = $row['image_id']; $image_filename = "uploaded_images/" . $image_id . ".jpg"; $image = getRandomImage($image_filename); echo 'The value of image is: ' . $image . '<br \>'; echo "<img src='$image_filename' width='519' height='353' border='0' usemap='#Map' \>"; } ?>
  3. aftab_jii

    SQL

    that worked thanks
  4. aftab_jii

    SQL

    i want to show last two posts where posts with category About Me and Our Services are skipped. i managed to do it with the query below, but it only returns one post if the next post has category About Me or Our Services. i want the sql to skip the two categories and show two posts $sql = "SELECT article_id FROM articles WHERE is_published=1 AND category <> 'About Me' AND category <> 'Our Services' ORDER BY date_published DESC LIMIT 0,2"; $sql_result = mysql_query($sql) or die('Could not run query; ' . mysql_error()); i tried with SKIP (category = 'About Me') but got an error
  5. okey..managed to solve it.. here is how: //compose.php [b]<h2>Compose Article</h2> <form method="post" action="transact-article.php?category=" . <?php echo $row['article_category']; ?> \> <?php if ($row['category'] != "") { ?> <p><br> Article curretly published in <font color='red'><?php echo $category;?></font> </p></br> <?php } else { echo ""; } $sql = "SELECT * FROM article_category WHERE status = '1' ORDER BY article_category ASC"; $result = mysql_query($sql) or die('Could not list access levels; ' . mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { $c = $row['article_category']; echo '<input type="radio" name="category" value="' . $c . '" checked \>'; echo ' ' . $c; echo ' '; } [/b]?> <p> Title:<br> <input type="text" class="title" name="title" maxlength="255" value="<?php echo htmlspecialchars($title); ?>"> </p> <p> Body:<br> <textarea class="body" name="body" rows="10" cols="60"><?php echo htmlspecialchars($body); ?></textarea> </p> <p> <?php echo '<input type="hidden" name="article" value="' . $article . "\">\n"; if ($_SESSION['access_lvl'] < 2) { echo '<input type="hidden" name="authorid" value="' . $authorid . "\">\n"; } if ($article) { echo '<input type="submit" class="btn" name="action" ' . "value=\"Save Changes\">\n"; } else { echo '<input type="submit" class="btn" name="action" ' . "value=\"Submit New Article\">\n"; } ?> </p> </form> and the changes in transact-aticle.php case 'Submit New Article': if ([b]isset($_POST['category'])[/b] and isset($_POST['title']) and isset($_POST['body']) and isset($_SESSION['user_id'])) { $sql = "INSERT INTO articles " . "(category, title, body, author_id, date_submitted) " . "VALUES ('" . [b]$_POST['category'][/b] . "','" . $_POST['title'] . "','" . $_POST['body'] . "'," . $_SESSION['user_id'] . ",'" . date("Y-m-d H:i:s", time()) . "')"; mysql_query($sql, $mylink) or die('Could not submit article; ' . mysql_error()); } redirect('cpl.php'); break;
  6. i have moved it inside the <form></form> but still nothing happens
  7. Hi, I've made an upload script that uploads the images and files into a directory /uploaded_items that is under /www on my web-hotell is there a way to hide the source for the images and files so that when someone right-clicks he either gets some gibbrish or just image="/"
  8. Hi, I am having a little bit of trouble passing the value of radio-button into a mySQL database. The script below (compose.php) reads the value of article_category from table article_category But the values does not pass on to mySQL table..the column category in table articles (transact-article.php) remains empty. Can anyone tell me what i am missing? <?php //compose.php require_once ('files/configure_impressions.php'); $title = ''; $body = ''; $article = ''; $authorid = ''; if (isset($_GET['a']) and $_GET['a'] == 'edit' and isset($_GET['article']) and $_GET['article']) { $sql = "SELECT category,title,body,author_id FROM articles " . "WHERE article_id=" . $_GET['article']; $result = mysql_query($sql, $mylink) or die('Could not retrieve article data; ' . mysql_error()); $row = mysql_fetch_array($result); $title = $row['title']; $body = $row['body']; $article = $_GET['article']; $authorid = $row['author_id']; } ?> <h2>Compose Article</h2> <?php $sql = "SELECT * FROM article_category ORDER BY article_category ASC"; $result = mysql_query($sql) or die('Could not list access levels; ' . mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { echo '<input type="radio" name="category" value="' . $row['article_category'] . '">'; echo ' ' . $row['article_category']; echo ' '; } ?> <form method="post" action="transact-article.php?category="<?php echo $row['article_category']; ?>" \> <p> Title:<br> <input type="text" class="title" name="title" maxlength="255" value="<?php echo htmlspecialchars($title); ?>"> </p> <p> Body:<br> <textarea class="body" name="body" rows="10" cols="60"><?php echo htmlspecialchars($body); ?></textarea> </p> <p> <?php echo '<input type="hidden" name="article" value="' . $article . "\">\n"; if ($_SESSION['access_lvl'] < 2) { echo '<input type="hidden" name="authorid" value="' . $authorid . "\">\n"; } if ($article) { echo '<input type="submit" class="submit" name="action" ' . "value=\"Save Changes\">\n"; } else { echo '<input type="submit" class="submit" name="action" ' . "value=\"Submit New Article\">\n"; } ?> </p> </form> <?php . . . . . //transact-article.php case 'Submit New Article': if (isset($_GET['article_category']) and isset($_POST['title']) and isset($_POST['body']) and isset($_SESSION['user_id'])) { $sql = "INSERT INTO articles " . "(category, title, body, author_id, date_submitted) " . "VALUES ('" . $_GET['article_category'] . "','" . $_POST['title'] . "','" . $_POST['body'] . "'," . $_SESSION['user_id'] . ",'" . date("Y-m-d H:i:s", time()) . "')"; mysql_query($sql, $mylink) or die('Could not submit article; ' . mysql_error()); } //redirect('cpl.php'); break; . . . . ?>
  9. im working with a PHP form that reads values from a database and an AJAX code that autocompletes the values.. what i am having problem with is that each felt reads all the values from all the columns in the database.. take a look at the screen shoot The values RAPE110 and ABC Stal are from one table but two differnt columns I need help to sort out what i ha ve to do so that the textfields get/shows values that belong to the column The PHP code where i define the column look like: <td id="text">Mal artikkel:</td> <td> <input type="text" name="malartikkel" size="20" maxlength="40" value="<?php if (isset($_REQUEST['malartikkel'])) echo $_REQUEST['malartikkel']; ?>" /> <div id="hint"></div> <script type="text/javascript"> new Ajax.Autocompleter("malartikkel","hint","server.php"); </script> </td> </tr> <tr> <td id="text">Leverandørens navn:</td> <td> <input type="text" name="leverandorsnavn" size="40" maxlength="40" value="<?php if (isset($_REQUEST['leverandorsnavn'])) echo $_REQUEST['leverandorsnavn']; ?>" /> <div id="hint"></div> <script type="text/javascript"> new Ajax.Autocompleter("leverandorsnavn","hint","server.php"); </script> </td> and the sql (which is defined in server.php) looks like: $sql = "SELECT malartikkel, leverandorsnavn FROM varebest WHERE malartikkel LIKE '%" . $_POST['search'] . "%'" . " AND leverandorsnavn LIKE '%" . $_POST['search'] . "%'"; $rs = mysql_query($sql); ?> <ul> <? while($data = mysql_fetch_assoc($rs)){ ?> <? //echo stripslashes($data['malartikkel']); echo stripslashes($data['produktbeskrivelse']); echo stripslashes($data['malartikkel']); ?> <? } ?> </ul>
  10. can anyone help me with this... i have set up mail($email, $subject, $message) on a windows 2000 server but i dont get any mail at all.. what sort of properties should i change in php.ini file? we are using LotusNotes and it has a serveraddress that looks like: abcserver/abc/com
  11. i managed to fix it.. thankyou for the quick response
  12. now it gives me an error no matter if the salesman is selected or not
  13. i have trid to install PHP on a windows 2000 server but i dont get it to work... the tutorial i have followed is: http://forums.kayako.com/showthread.php?t=4066 i have trid both: This is how you set the website to use PHP as CGI. and To change from CGI to ISAPI saprately but the page: http://localhost/test.php (which is a phpinfo() ) does not show up and neiter does anyother php pages... can anyone help.. the browser shows me the dafault error page saying that the page im looking for does not exists..
  14. can someone please help me creating a check for the following drop-down: i have tried something like this: but its not seem to be working
  15. okey.. i have a really complex query.. the reason im asking this is to save my time.. i have two mysql databases..herezz the structure.. Database A (old): It has about 150 users with permissions to about 5 to 10 application Every application can be given and denied permission to a function within the application by setting 0 and 1..the data for the users looks something like this: Username Application Name Function1 Function2 Function3 Function4 Function5 Function6 -------------------------------------------------------------------------------------------- XYZ Sales 1 0 0 1 1 1 ABC Sales 1 1 1 0 0 0 Database B (new): In this database the users are assigned groups and the rest of the table is the same: Username Group Application Name Function1 Function2 Function3 Function4 Function5 Function6 --------------------------------------------------------------------------------------------------- XYZ Logistics Sales 1 0 0 1 1 1 ABC Logistics Sales 1 1 1 0 0 0 Now what i want to do is to copy the data for each function from Database A into Database B so that the permissions in the Database B would be same as Database A...since the only differnce is that in Database B the users are assigned groups.. can anyone help me please
×
×
  • 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.