Jump to content

backinblack

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

backinblack's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have a code that does a random image every time they come to the site but for some reason it is not working. I must be missing something. Can some one help me out? <?php $images = array('pic1', 'pic2', 'pic3'); $i = rand(0, count($images)-1); $selectedImage = "images/{$images[$i]}.jpg"; ?>
  2. I have two form fields that are duplicated like this shown below. Since they are duplicate I have even tried to put then in a array but it goes in the mysql as array and what I have shown below in enters just the last one. It actually will have up to 20 instead of the 2 I show. I am trying this so I don't have to enter one at a time. Is this possible? I can't find anthing talking about the same name values in a form. <html> <head> <title>Address form</title> </head> <body> <form action="processform.php" method="post"> <table> <tr><td><input type="text" name="yourname" length="20"></td><td><input type="text" name="address"></td> </tr> <tr><td><input type="text" name="yourname" length="20"></td><td><input type="text" name="address"></td> </tr> </html> </body> </html> ---------------------------------------------------------------------------- //processform.php <?php $carnumber = $_POST['name']; $name = $_POST['address']; $host=""; $user=""; $password=""; $database = ""; $connection = mysql_connect($host,$user,$password) or die ("Could not retrieve information"); $db = mysql_select_db($db,$connection) or die ("Could not make connection"); $query = "INSERT INTO clients values ('$name', '$address')"; $results=mysql_query($query) or die (mysql_error()); if ($results); echo 'Your information has been added!'; ?>
  3. I have rename it before and it did not work. Some thing that should be fairly easy is drving me nuts. I have two rows of three input fields. Is there away to name each one differently for the update? Because I think this is part of my problem.
  4. I have done it with out using them as an array but then it only updates the last one. The reason for that is all the input names are the same. Some how I have to get them different. I have read several turtorials and it just does not make sense.
  5. I have just two rows of three input fields now but it will be up to 25. <form action="april15pts.php" method="post"> <table width="30%"><tr><td width="5%"><b>Car #:</b> </td><td width="15%"><b>Name:</b></td> <td width="5%"><b>Points:</b></td></tr> <td><input type="text" name="carnumber[]"></td><td><input type="text" name="name[]"></td><td><input type="text" name="april15pts[]"></td></tr> <tr><td><input type="text" name="carnumber[]"></td><td><input type="text" name="name[]"></td><td><input type="text" name="april15pts[]"></td></tr> <tr><td><input type="submit" value="Send Results"></td></tr> </table> </form>
  6. Well I ran it in phpmyadmin and it does nothing. It just shows that no rows were affected which I already knew. For some reason I do not think it reconizes the $april15pts variable. I can put any thing else in there like 50 and it will update then. I am confused. Please help.
  7. I know there are alot of people that have asked about updates and I have read most of them. It seems to me I have the same thing as alot of people and they got there to work. Mine will not update it. It acts like it did but it don't. I have four columns in my database--driver_id, carnumber, name, april15pts(more dates will be added later)Car Numbers and names are already in there. I just want to update the april15pts column. Here is what I have. I have a form with the text areas carnumber, name, and april15pts which goes to this process page. <?php $carnumber = $_POST['carnumber']; $name = $_POST['name']; $april15pts = $_POST['april15pts']; $host = "xxxxxxx"; $user = "xxxxxxx"; $password = "xxxxxx"; $database = "xxxxxxx"; $connection = mysql_connect($host, $user, $password) or die ("Could not retrieve information"); $db = mysql_select_db("databasename",$connection) or die ("Could not make connection"); $query = "UPDATE points SET april15pts='$april15pts' WHERE carnumber='$carnumber' AND name='$name'"; $results=mysql_query($query) or die (mysql_error()); if ($results); echo 'Result have been posted into database!'; ?> I have read that you are not suppose to use AND --and just use a comma but when I do that I get an error. What the heck am I doing wrong?
  8. Whew! Got it figured out. Thank you all for the help. AndyB you put me on the right track. Usually when people start throwing out ideas, the light bulb will usually come on for me and can figure it out myself. My next problem though is each week of course the points will be different and when I do that it duplicates the drivers car number and name. If I get stuck I will hit you guys up for more info. THANKS AGAIN!!
  9. That is what I already had . I am trying to avoid that if I can. I am pretty sure there is a way. Just trying to figure out how. My rows in my table is driver_id which is the primary key set to auto increment and notnull carnumber name points
  10. Ok I think I am getting closer. What I have is the six form fields I have carnumber[] name[] points[] etc... then to process it I have $query = "INSERT INTO points values ('$carnumber[0]', '$name[1]', '$april15pts[2]'), ('$carnumber[3]', '$name[3]', '$april15pts[4]')"; But by doing it this way I get an error saying: Column count doesn't match value count at row 1 From all the different turtorials that I have read, it looks like there are several ways to do this and I can seem to figure it out.
  11. I am pretty new to this so please bare with me. I have renamed all the form values. For instance... carnumber[0] name[1] points[3] on the first row of the form input fields and carnumber[4] name[5] points[6] on the second row of fields. For the array can I just name it anything like this $carnumber = array('carnumber', 'name', 'points')
  12. I have driver_id as my primary key set to auto increment but did not have it set to null. Changed that and put the driver_id in the query but still does the same thing.
  13. Form I just put a couple of the fields to keep it short. Only submit the form once and it just puts the last one in the database. <form action="ptsprocess.php" method="post"> <table width="30%"><tr><td width="5%"><b>Car #:</b> </td><td width="15%"><b>Name:</b></td> <td width="5%"><b>Points:</b></td></tr> <td><input type="text" name="carnumber"></td><td><input type="text" name="name"></td><td><input type="text" name="points"></td></tr> <tr><td><input type="text" name="carnumber"></td><td><input type="text" name="name"></td><td><input type="text" name="points"></td></tr> <tr><td><input type="submit" value="Send Results"></td></tr> </table> </form> <?php $carnumber = $_POST['carnumber']; $name = $_POST['name']; $points = $_POST['points']; $host = "XXXXXXX"; $user = "XXXXXXX"; $password = XXXXXXX"; $database = "XXXXXXX"; $connection = mysql_connect($host, $user, $password) or die ("Could not retrieve information"); $db = mysql_select_db("databasename",$connection) or die ("Could not make connection"); $query = "INSERT INTO points (carnumber, name, points)" . "VALUES ('$carnumber','$name','$points')"; $results=mysql_query($query) or die (mysql_error()); if ($results); echo 'Result have been posted into database!'; ?> AndyB-- You are correct. That is what is messing things up I think. Trying to figure out the correct way to do this.
  14. I am having a little dificult figuring this out. Hope some on cane help. Still pretty new here. I am doing a website for a race track and what I am trying to do is when I get the results all the info goes to the database. The form is like this: It has Car#, Drives Name, Points. 1. #50 Bob Smith 50pts 2. #20 John Doe 48pts and so on up 25 fields, but when I send the it, it will only show the last one. It will not send all of them. I want to have all the car numbers in the car numbers field in the database with the drivers name and points the same way. This is probably simple but I am drawing a blank. Can any one help?
  15. [code] <?php echo "<html>          <head><title>Profiles</title></head>          <body>"; $host="xxxxxx"; $user="xxxxxx"; $password="xxxxxx"; $database = "xxxxxx"; $connection = mysql_connect($host,$user,$password)     or die ("Could not retrieve information"); $db = mysql_select_db("database",$connection)     or die ("Could not make connection"); $query = "SELECT * FROM driverprofiles"; $result = mysql_query($query)     or die("Sorry!Could not retrieve the information"); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $fullname=mysql_result($result,$i,"fullname");   echo "$fullname <br>" ; $i++; } echo "</body></html>"; ?> [/code] From above code I am pulling there fullname from the database. Say I have ten names there but they do not have links to there profile yet. I am trying to figure how to be able to link to each individual name to go to their profile when it come from the database. Then some how with all there information in the database do I have to make another page that calls thier information?
×
×
  • 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.