Jump to content

floridaflatlander

Members
  • Posts

    671
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by floridaflatlander

  1. Like I said I'm new to this and work within what I've done before,

     

    Here's how I think would do it, of course I haven't tested it.

     

    // Get a random #

    $result = "SELECT * FROM totem_ads";

    $result = mysqli_query ($dbc, $result); // Connect to the database connection defined in your include() & run the query

    $result = mysql_num_rows($result); // This gets the number of rows

    $random_row = rand(1, $result); // If a row is deleted ot missing your rand() will show a null if it lands on it.

     

    // Use the random number to get a random row

    $randon_row = "SELECT * FROM totem_ads WHERE rownum(column_name) = $random_row"; // is rowmun a column ?

    $ad_sql = mysql_query($dbc,$random_row); // Connect again to the database defined in the include() ..

    while($row_advert = mysql_fetch_array($ad_sql))

     

    ----------

    Someone with more experience may have more info or be able to trim this up a bit.

    --------------------------------------

     

    Use an echo statement some where on your page to see if your getting a $random_row value, echo "$random_row";

     

    My suggestion is to play with it, I've spent a half a day on stuff like this only to find out it was something very simple.

  2. I'm begining PHP too so take this with some salt.

     

    Where are you connecting to the database?

     

    Do your rows have id's ? Are they auto increments?

     

    You "may be able to" use a query something like this

     

    $q = "SELECT COUNT (column name ) FROM totem_ads";

    $r = mysqli_query ($dbc, $q); // Run the query

    $random_row = rand(1, $r);

     

    or

     

    $q = "SELECT * FROM totem_ads"; (I used the same as you to get a number)

    $r = mysqli_query ($dbc, $q); // Run the query

    $num = mysqli_num_rows($r); // Count records

    $random_row = rand(1, $r);

     

    What are you going to do if you delete a row? Do you have a query to run rand() again it hits a deleted row?

     

     

  3. On your local host, make a form, and enter your data. Then write the code to display the enteries, than write code to edit the entries, then work on security for your site. If you're the only one entering data, that will be easy. If you have multple people entering ads(like I hope to do one day), that's another story.

     

    You may want to follow this

     

    http://www.phpfreaks.com/forums/application-design/idea-for-classified-ads-website/msg1523976/

  4. This is interesting, I always thought the browser would render the page to make the table above but I cut and pasted the html in a file and looked at it in my browser and nothing happened (it looked the same).

     

    Isn't this a bit like safe html, does the server format the code before sending it to the browser ?

     

    I tried a space,   in the same page and it worked fine.

  5. Your form may look something like this, of course you also may have to change a few values here and there

     

    <form action="movie.php" method="post">  ( or form action="<?php echo $_SERVER['PHP_SELF']; ?>" )

    <table class="table">

    <tr>

    <td colspan="2">

    <h1>Page Title</h1>

    </td>

    </tr>

    <tr>

    <td>

    <p>Title:</p>

    </td>

    <td>

    <p><input type="text" name="Title" size="20" maxlength="80" /></p>

    </td>

    </tr>

    <tr>

    <td>

    <p>URL:</p>

    </td>

    <td>

    <p><input type="text" name="url" size="20" maxlength="100" /></p>

    </td>

    </tr>

    <tr>

    <td>

    <p>Category:</p>

    </td>

    <td>

    <p><input type="text" name="category" size="20" maxlength="20" /></p>

    </td>

    </tr>

    <tr>

    <td colspan="2" align="right">

    <input type="submit" name="submit" value="Enter" />

    </td>

    </tr>

    </table>

    </form>

  6. My question is what do you consider the best tutorials for php? Is there one that gives many examples? I can find javascripts for just about anything I want to do. Is there such a site for php where they can be downloaded or copied? The free stuff of course.

     

    I think this is what he was talking about Maq

  7. To me head first is squirrelly.

     

    I bought, head first, Larry Ullman's php6 & 5  and Ullman's php 3rd edition in that order. It was all French to me until I got Ullman's  php 3rd edition, it's for people just starting out with php.

    Some people don't like Ullman's two column style but it's Okay with me. It's a beginners book and it's to the point with the info in it that you asked for in your post.

     

    If I had it all to do over again with my skill set, I'd go

    Larry Ullman's  php 3rd edition. then

    Larry Ullman's php6 & 5 and/or  Luke Welling & Laura Thomson's  PHP & MySQL.

     

    Also I just got David Powers PHP Solutions and it's great.  It's like you build a site with a photo gallery with thumbs nails and a simple content management system, it addresses style also, kind of like the Zend css stuff. It also talks about problems that can arise when multiple people upload info to your site and how to fix the problems(some of these problems weren't addressed by Ullman or Welling/Thomson). Even though it's simple it is not for people without php experience. If you went from Larry Ullman's  php 3rd edition, then David Powers PHP Solutions you may be pleased, in fact with your back ground you may be able to go straight to Powers' book. Powers' php solutions first edition is available on the web and for cheap at amazon.

  8. I'd do it like this

    $result1 = mysql_query("SELECT id, namn, url FROM stuff ORDER BY id desc limit 1;")

    $link1 = $result1;

     

    $result2 = mysql_query("SELECT id, namn, url FROM stuff ORDER BY id desc limit 1,1;");

    $link2 = $result2;

     

    <html>

    <a href="<echo ''.$link1.'';?>"> <p class="note-general"> The first link </p></a>

    <a href="<echo ''.$link2.'';?>"> <p class="note-general"> The the second link </p></a>

    </html>

    (should the href be inside of the p tag?)

     

  9. I tried the free down load of Microsoft expressions 4. Of course the css is great but the php editor has something missing. It's colors are pretty but when you try to find a closing bracket or parenthesis to a condition it doesn't highlight them like other programs, also you can't collapse conditions either.

     

    If someone is using this, am I doing something wrong? Does Expression 4 highlight brackets and parenthesis?

     

    I'm thinking of buying Nu-sphere as a php editor but wanted to double check expressions because of its css editing and just to see if I was doing anything wrong.

     

    I know I could post this on their forum and I was a member, but it's been about 6-7-8 months since I posted anything and they want me to re-register and get a windows live ID to post. Soooo here I am.

     

    Thanks in advance

    S

×
×
  • 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.