
stonebergftw
Members-
Posts
14 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
stonebergftw's Achievements

Newbie (1/5)
0
Reputation
-
Can you explain what the following line is doing? $data[$id] = explode('"', $tmp[1], -1);
-
This definitely works. Now I'll just write code to pull only the data I need. Thank you sir.
-
I solved this mysql by using preg_match. However, I'm still trying to figure out how to get it to find every occurrence, as it seems to be stopping after the first.
-
I have a problem that I don't know what to call. It's simple I think. I have file.txt . In this file there are a lot of entries,some of which contain the string Goober######", where # is 1-infinite random character/s. This string always ends with the character, ". I need to go through file.txt and write each occurrence to an array. Can someone help me with the syntax for this?
-
Thanks a ton friend.
-
Say, $ok = 'ABCDEFG' What is the command to check whether $ok contains 'C'?
-
I fixed the problem with the following code: <?php $donor=@mysql_query('SELECT id, locationname FROM donors'); <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <label>Donor: <select class="text" name="donor"> <option value=new>Add a new donor...</option> <?php while ($donors=mysql_fetch_array($donor)) { $donorname=$donors['locationname']; $donorid=mysql_query("SELECT id FROM donors WHERE locationname='$donorname'"); $donorid=mysql_fetch_array($donorid); echo "<option value='$donorid[id]'>$donorname</option>"; } ?> I think my code is pretty sloppy though. Oh well.
-
Oops, that was a mistake, but... Is there something wrong with the following code? As far as I understand, the value should change with every iteration of the while loop. Not working though :\ <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <label>Donor: <select class="text" name="donor"> <option value=new>Add a new donor...</option> <?php while ($donors=mysql_fetch_array($donor)) { $donorname=$donors['locationname']; echo "<option value='<?php echo $donorname;?>'>$donorname</option>"; //echo "<option value='hi'>hi</option>"; } ?> </option> </select>
-
filling a drop down select box from MYSQL table
stonebergftw replied to stonebergftw's topic in MySQL Help
Rules noted. Ok, to specifics. Can you explain why this is not working? I think there is something wrong with the following: echo "<option value='<?php echo $donorname;?>'>$donorname</option>"; Out of the following code: <?php $donor=@mysql_query('SELECT id, locationname FROM donors'); ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <label>Donor: <select name="donor"> <?php while ($donors=mysql_fetch_array($donor)) { $donorname=$donors['locationname']; echo "<option value='<?php echo $donorname;?>'>$donorname</option>"; } ?> </select> <input type="submit" value="SUBMIT"/> </form> There could be something wrong with this code block, but I'm really not sure: <?php $locationname = $_POST['donor']; $donorid = mysql_query("SELECT id FROM donors WHERE locationname='$locationname'"); $sql = "INSERT INTO donations SET donorid='$donorid'"; mysql_query($sql); ?> The select list reads the data just fine, but the INSERT INTO donations SET donorid='$donorid'" is not executing properly. Lets assume that all MYSQL tables are correct and the format of the tables is irrelevant. Any ideas? Help is really really appreciated. -
Is there any way to fill a <select> box with entries from a mysql table, and then to have the entries POST to fill in another mysql table. Example. MYSQL table 1 id name 1Tim 2Joe 3Bob Have a drop down select box from table 1, and then fill in the selections in the auto-incrementing table 2, formatted as follows: MYSQL table 2 id name Is this even possible?
-
I'm having trouble getting the dynamic data from my <select> menus to write into my MYSQL database. Can anyone see what I'm doing wrong here? First post btw The output looks like this, which is obviously wrong: <html> <head> </head> <link rel="stylesheet" type="text/css" href="./css/newuser.css" /> <body> <?php session_start(); require 'default.inc.php'; ?> <?php if (isset($_POST['amount'])): $host = 'localhost'; $user = 'user'; $pass = 'password'; $conn = mysql_connect($host, $user, $pass); if (!$conn) { exit('<p>Unable to connect to the database server</p>'); } if (!@mysql_select_db('spikesusers')) { exit('<p>Unable to locate the database</p>'); } $locationname = $_POST['donor']; $donorid = mysql_query("SELECT id FROM donors WHERE locationname='$locationname'"); $amount = $_POST['amount']; $year = $_POST['year']; $type = $_POST['type']; $typeid = mysql_query("SELECT id FROM donationtype WHERE type='$type'"); $player = $_POST['player']; //$playerid = mysql_query("SELECT id FROM players WHERE $sql = "INSERT INTO donations SET donorid='$donorid', amount='$amount', yearofdonation='$year', typeid='$typeid'"; mysql_query($sql); ?> <div class='standard'> <h1>Donation Management</h1> <?php if ($sql) { echo "New donation added "; echo "<p></p>"; echo "<a href=managedonations.php>Back to donation management</a>"; exit(); } else { echo "Error adding new donation"; echo "<a href=adddonation.php>Try again</a>"; exit(); } ?></div> <?php else: $host = 'localhost'; $user = 'user'; $pass = 'pass'; $conn = mysql_connect($host, $user, $pass); if (!$conn) { exit('<p>Unable to connect to the database server</p>'); } if (!@mysql_select_db('spikesusers')) { exit('<p>Unable to locate the database</p>'); } $donor=@mysql_query('SELECT id, locationname FROM donors'); ?> <div class='standard'> <h1>Donation Management</h1> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <label>Donor: <select class="text" name="donor"> <option value=new>Add a new donor...</option> <?php while ($donors=mysql_fetch_array($donor)) { $donorname=$donors['locationname']; echo "<option value='<?php echo $donorname;?>'>$donorname</option>"; //echo "<option value='hi'>hi</option>"; } ?> </option> </select> </label><br /> <label>Amount: <input class="text" type="text" name="amount" class="text" /></label><br /> <label>Year of donation: <select class="text" name="year"> <option value='2011'>2011</option> <option value='2010'>2010</option> <option value='2009'>2009</option> </select> </label><br /> <?php $player=@mysql_query('SELECT id, firstname, lastname FROM players'); ?> <label>Player: <select class="text" name="player"> <option value="player" selected="selected"></option> <?php while ($players=mysql_fetch_array($player)) { $playerfirstname=$players['firstname']; $playerlastname=$players['lastname']; echo "<option value=player>$playerfirstname $playerlastname</option>"; } ?> </select> </label><br /> <?php $type=@mysql_query('SELECT id, type FROM donationtype'); ?> <label>Donation type: <select class="text" name="type"> <?php while ($types=mysql_fetch_array($type)) { $donationtype=$types['type']; echo "<option value=type>$donationtype</option>"; } ?> </select> </label><br /> <input type="submit" value="SUBMIT" class="buttons"/> <input type="button" name="Cancel" value="CANCEL" onclick="window.location = 'managedonations.php'" class="buttons"/> </form> </div> <?php endif; ?> </body> </html>