Jump to content

nextman

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

nextman's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. im trying to display the 6 articles in dofferent locations on the same page. im trying this now but its not displaying the article ids: $sql = "SELECT * FROM art_articles WHERE status = '1' ORDER BY date DESC LIMIT 6"; $result = mysql_query($sql); $i = 0; $res = array(); while($row = mysql_fetch_assoc($result)) { $res[++$i] = $row; } echo $row[1]['id']; echo $row[2]['id']; echo $row[3]['id']; echo $row[4]['id']; echo $row[5]['id']; echo $row[3]['id']; :s
  2. thanks guys, im trying to use the first bit of code you suggested. heres what i got: // Get latest articles $sql = "SELECT * FROM art_articles WHERE status = '1' ORDER BY date DESC LIMIT 6"; $result = mysql_query($sql); $i = 0; $res = array(); while($row = mysql_fetch_assoc($result)) { $res[++$i] = $row; } $row1id = $row[1]['id']; $row2id = $row[2]['id']; $row3id = $row[3]['id']; $row4id = $row[4]['id']; $row5id = $row[5]['id']; $row6id = $row[6]['id']; but i cant seem to get it to work. is there something wrong with my code?
  3. hi, i need some help with numbering rows in a mysql table after i select them. ill be brief, im going to run a mysql query that selects the 6 latest articles from my database , id like to assign a number to each of the rows it selects. ie, it pulls 6 rows and the first row is $1, the second row is $2 and the third row is $3 etc. any help would be appreciated
  4. im trying to fix an image rotator on my site to display dynamic content but im having trouble with the thumbnails. i need some php to put out this code: <a href="#1" class="cross-link active-thumb"><img src="/images/art/31thumb.jpg" class="nav-thumb" alt="temp-thumb" /></a> <div id="movers-row"> <div><a href="#2" class="cross-link"><img src="/images/art/32thumb.jpg" class="nav-thumb" alt="temp-thumb" /></a></div> <div><a href="#3" class="cross-link"><img src="/images/art/33thumb.jpg" class="nav-thumb" alt="temp-thumb" /></a></div> <div><a href="#4" class="cross-link"><img src="/images/art/34thumb.jpg" class="nav-thumb" alt="temp-thumb" /></a></div> <div><a href="#5" class="cross-link"><img src="/images/art/37thumb.jpg" class="nav-thumb" alt="temp-thumb" /></a></div> <div><a href="#6" class="cross-link"><img src="/images/art/30thumb.jpg" class="nav-thumb" alt="temp-thumb" /></a></div> </div> the image source is dynamic and i know how to grab it but i dont know how to get the integers for the href tag. also, another problem is that the first integer goes outside the "movers-row" div. this is what i have at the moment: {foreach from=$articles item=latest_article key=id} <div id="movers-row"> <div><a href="" class="cross-link"><img src="/images/art/{$articlethumb}.jpg" class="nav-thumb" alt="temp-thumb" /></a></div> {/foreach} </div> help
  5. UPDATE: got it working. heres the code i used, its pretty simple - sums up a column and displays it: <?php $sqla= "SELECT SUM(column_name) AS Total FROM table_name"; $result = mysql_query($sqla) or die (mysql_error()); while ($myrow = mysql_fetch_array($result)) { $total=$myrow["Total"]; echo 'The total is '.$total.''; } ?>
  6. just to add to that, i have this code: <?php $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); $query = ("SELECT SUM(site_views) FROM pm_videos"); $result = mysql_query($query); echo "$result"; ?> but all i get back is "Resource id #2"
  7. i have a column in a mysql table, and id like to find the sum of the values inside it. any way to do this?
×
×
  • 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.