Jump to content

spiderwell

Members
  • Posts

    1,008
  • Joined

  • Last visited

Posts posted by spiderwell

  1. oh relax, all posts die of their own accord eventually

     

    No one is making you come back here, and it is marked solved so why even read it if it bothers you that much!

     

    there is some irony in your post as you are doing exactly what you are protesting about!

     

     

  2. I am pretty sure that there isnt a way to collectively 'show all sessions' in php, but I might be wrong.

    The alternative would be to have another table in the database that you update with users when the login and logout (or timeout) so you keep a tally of who is online, and do it that way.

     

    Back in the day of classic asp you could use application level variables that were great for keeping track of things like this, I am not sure if php has such things.

  3. this is why i often advise people to never have such large drives, i personally never have a drive over 500gb

    No reason for the advice if they are doing proper backups (onsite AND offsite) ;)

    I hear what you are saying but this is usually advice to friends, not professional environments, and not many home users do backups, they see 2TB drive only £70, think I'll have some of that, fill it with data, and when(if) it fails lose everything in 1 shot.

  4. i have 4 vehiclesales entries, and vehicleimages has like 4 images with the same vehicleID, so when i run the statement i get like 16rows back which repeat the vehiclesales each time with a different image in the row, so the same vechiclesale appears 4times when i just want 1

    so im trying to pull out each vehiclesale with an image but i dont want the sql to repeat the vehiclesales with each image that has a matching vehicleid

     

    i hope that makes sense

  5. you still need the while statement to loop through the record set:

    <table class="Main" width="65%" cellpadding="0" cellspacing="0">
    <tr><td class="Tableheading">Newspaper</td></tr>
    <tr><td class="subtableheader"><img src="images/newspaper.jpg" alt="paper"/></td></tr>
    </table>
    
    <table width=100% class=table>
    
    <?
    $select = mysql_query("SELECT * FROM paper WHERE edition=1 ORDER by id ASC");
    
    while($the=mysql_fetch_object($select_paper)){
    
    ?>
    <tr>
    <td>
    <td width=50% style=border: none; background-color: transparent; valign=top>
    
    
    			<table border=1 cellpadding=0 cellspacing=0 bordercolor=#000000 class='main' align=center>
    				<tr>
    				  <td width=500 class='tableheading'><?php echo "$the->title"; ?><center>
    				  </center></td>
    			  </tr>
    				<tr >
    					<td class="profilerow" align=left><center><?php echo "$the->news"; ?>
    </td>
    			  </tr>
    				<tr >
    					<td  class="subtableheader" align=left><center><?php echo "Article By $the->by - $the->date"; ?>
    </td>
    			  </tr>
    		  </table>
    	</td>
    </tr>
    <?
    }
    ?>
    </table>
    </html>
    

  6. well i think because it has a half finished table in the html part

     

    try this:

     

    <?
    $select_paper=mysql_query("SELECT * FROM paper WHERE id=1");
    while($the=mysql_fetch_object($select_paper)){
    ?>
    
    
    			<table border=1 cellpadding=0 cellspacing=0 bordercolor=#000000 class='main' align=center>
    				<tr>
    				  <td width=500 class='tableheading'><?php echo "$the->title"; ?><center>
    				  </center></td>
    			  </tr>
    				<tr >
    					<td class="profilerow" align=left><center><?php echo "$the->news"; ?>
    </td>
    			  </tr>
    				<tr >
    					<td  class="subtableheader" align=left><center><?php echo "Article By $the->by - $the->date"; ?>
    </td>
    			  </tr>
    		  </table>
    <br>
    
    <? } ?>
    

  7. have you tried putting the sql you want in place of the current sql, that should do it really, perhaps with LIMIT 15 tacked on the end of the sql so only 15 records return.

     

    $select_paper=mysql_query("SELECT * FROM paper WHERE edition=1 ORDER by id ASC LIMIT 15");

  8. if its the sql line then its probably the extra ' i put in, i did say i wasn't sure about that one. however the undefined index at that line for class is appearing for the reason mentioned previously

     

    it would be better off being re written completely. I havent checked this code for syntax errors but it is probably ok:

     

    $username = (isset($_POST['username'])) ? $_POST['username'] : false; // if its set, grab it otherwise false
    $password= (isset($_POST['password'])) ? $_POST['password'] : false;
    $class= (isset($_POST['class'])) ? $_POST['class'] : false;
    if (!$username|| !$password || !$class ) // if any are false
    {
    //some code to prevent non entered fields perhaps
    }
    else
    {
    //some other code here perhaps to santize the data, maybe also use md5 or sha1 to not store password in text format
    $sql="INSERT INTO register (username, password, class) VALUES ('$username','$password','$class')";
    }
    

  9. it is saying that $_POST['register'] does not exist.

     

    use isset($_POST['register']) to check if it exists, then pass it to a variable, the same occurs on class if none of the radio options are selected

     

    this line:

    $sql="INSERT INTO register (username, password, class) VALUES ('$_POST[username]','$_POST[password]','$_POST[class]')";

     

    has a few errors, the biggest one is putting unsantized data into an sql statement, this is not advised, it allows the possiblity of sql injections, the other part is that your ' are missing from the $_POST:

     

    $sql="INSERT INTO register (username, password, class) VALUES ('$_POST['username']','$_POST['password']','$_POST['class']')";  but you say it is working so maybe that bit isnt wrong? I am not 100% sure on that bit

     

     

  10. ok here is the structure of the 4 tables with also teh mysql version

    -- phpMyAdmin SQL Dump
    -- version 3.3.9
    -- http://www.phpmyadmin.net
    --
    -- Host: localhost
    -- Generation Time: Feb 22, 2012 at 07:34 PM
    -- Server version: 5.1.53
    -- PHP Version: 5.3.4
    
    SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
    
    --
    -- Database: `hoagysouthwest`
    --
    
    -- --------------------------------------------------------
    
    --
    -- Table structure for table `vehicleimages`
    --
    
    CREATE TABLE IF NOT EXISTS `vehicleimages` (
      `ID` int(11) NOT NULL AUTO_INCREMENT,
      `salesid` int(11) DEFAULT NULL,
      `image` text,
      `order` int(11) DEFAULT '0',
      PRIMARY KEY (`ID`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=41 ;
    
    -- --------------------------------------------------------
    
    --
    -- Table structure for table `vehiclemake`
    --
    
    CREATE TABLE IF NOT EXISTS `vehiclemake` (
      `ID` int(11) NOT NULL AUTO_INCREMENT,
      `make` text NOT NULL,
      PRIMARY KEY (`ID`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;
    
    -- --------------------------------------------------------
    
    --
    -- Table structure for table `vehiclemodel`
    --
    
    CREATE TABLE IF NOT EXISTS `vehiclemodel` (
      `ID` int(11) NOT NULL AUTO_INCREMENT,
      `makeid` int(11) DEFAULT NULL,
      `model` text NOT NULL,
      PRIMARY KEY (`ID`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ;
    
    -- --------------------------------------------------------
    
    --
    -- Table structure for table `vehiclesales`
    --
    
    CREATE TABLE IF NOT EXISTS `vehiclesales` (
      `ID` int(11) NOT NULL AUTO_INCREMENT,
      `makeid` int(11) NOT NULL,
      `modelid` int(11) NOT NULL,
      `title` text,
      `year` int(11) DEFAULT NULL,
      `date` date DEFAULT NULL,
      `price` int(11) DEFAULT NULL,
      `mot` text,
      `tax` text,
      `logbook` int(11) DEFAULT NULL,
      `mileage` int(255) DEFAULT NULL,
      `fuel` text,
      `transmission` text,
      `drive` int(11) DEFAULT NULL,
      `details` text,
      `forsale` int(11) NOT NULL DEFAULT '0',
      `ebay` bigint(200) DEFAULT '0',
      PRIMARY KEY (`ID`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ;
    

     

    What I am trying to achieve is a recordset of the vehiclesales, with vehiclemake, vehiclemodel and vehicleimages all joined on to give me a list of all the vehicle sales with just 1 row from the images. as it stands vehiclemodel and vehiclemake are 1 to 1 against vehiclesales, but vehiclesales to vehicleimages can be 1 to many, I just want it to return 1 image.

     

    I hope this is enough information for you

  11. you can call the input field anything you like in the html, just use the same name to retrieve it in the php when submited.

     

    <input type="text" name="record">

     

     

    <?

    $record = $_POST['record'];

    "SELECT * FROM mytable WHERE id = " . $record

    ?>

     

    of course you need to add security to this to prevent sql injection, but hopefully that gives you the idea

     

     

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