GingerRobot
Staff Alumni-
Posts
4,082 -
Joined
-
Last visited
Everything posted by GingerRobot
-
[SOLVED] making a loop that actually works.
GingerRobot replied to Badboy8's topic in PHP Coding Help
Try: foreach ($_POST as $key=>$val){ $$key = $val; } $poop=1; while($poop<4) { $dodo="a_".$poop; $sql = "UPDATE abc SET $dodo='$$dodo' WHERE id='$id'" mysql_query($sql,$db) or die(mysql_error()); $poop++; } As was said above, you need to be using another variable variable, It is needed in this line: $sql = "UPDATE abc SET $dodo='$$dodo' WHERE id='$id'" Since you want to be updating the field, not with a_1 for example, but with the value of $a_1 -
Firstly, welcome to the forum. Second, we're going to need to see far more of the code than that. Showing up the getPagingLink() function would be a good place to start, along with the links it generates Without any more, i can only guess at what the problem is. And my guess would be that you're only passing the page number and not passing the search criteria in the URL. Therefore, when the page loads, the search criteria are not set, so you are showing the search form. p.s. Try and remember to use the tags
-
[SOLVED] making a loop that actually works.
GingerRobot replied to Badboy8's topic in PHP Coding Help
Would be nice if you told us what you meant by 'not working'. However, i'd do something like: <?php $update = array(); for($x=1;$x<4;$x++){ $field = 'a_'.$x; $value = $_POST[$field]; $update[] = "$field ='$value'"; } $update_str = implode(',',$update); $sql = "UPDATE abc SET $update_str WHERE id='$id'"; mysql_query($sql) or die(mysql_error($sql.'<br />Query:'.$sql)); ?> -
I'd so something like this: <?php $sql = "SELECT DISTINCT UPPER(SUBSTRING(merchant,1,1)) AS first_letter FROM tbl ORDER BY first_letter"; $result = mysql_query($sql) or die(mysql_error()); while(list($letter) = mysql_fetch_row($result)){ echo '<a href="'.$_SERVER['PHP_SELF'].'?letter='.$letter.'">'.$letter.'</a> '; } if(isset($_GET['letter'])){ $letter = mysql_real_escape_string($_GET['letter']); $sql = "SELECT merchant FROM tbl WHERE merchant LIKE '$letter%'"; $result = mysql_query($sql) or die(mysql_error()); echo '<br /><br />'; while(list($merchant) = mysql_fetch_row($result)){ echo $merchant.'<br />'; } } ?> I know you said about using anchors; but with 10,000 records, there's going to be a lot of merchants beginning with some letters, meaning a lot of scrolling for the user. Therefore, i'd use the above with some pagination.
-
Oh no. He's going to go elsewhere with his questions. What a shame. Not.
-
Looks tab-delimited to me. Should just be a case of exploding by the tab and extracting the relevant information from the generated array. See: www.php.net/explode The separator will be "\t"
-
echo rows of images as on google images
GingerRobot replied to Vivid Lust's topic in PHP Coding Help
If you are just asking how to get the data from the database displayed in multiple columns, then see: http://www.phpfreaks.com/forums/index.php/topic,95426.0.html -
This sounds like more of an HTML issue to me. If you're wanting the data to be displayed in a list, with a horizontal rule in between, you shouldn't be using a table.
-
[SOLVED] Stuck,, need help to formulate this topic
GingerRobot replied to elpaisa's topic in PHP Coding Help
If memory serves, then the query should be: SELECT table1.imageid, table1.title FROM table1 LEFT JOIN table2 USING imageid WHERE table2.imageid IS NOT NULL -
Right, well with my omniscient hat on(which was required due to your vague description), im going to assume you have a line like this: if($user_supplied_password==$password){ //do something } And you're not sure how to check this if you now have multiple passwords in an array? If so, then, obviously, you need to create the array: $password= array('password1','password2'); You would then use the in_array() function in your if statement. If that wasn't what you were asking, try being a little bit more descriptive
-
So you already have something which is outputting these jobs, and you'd just like to add in a horizontal rule tag in between? If so you'll need to identify the relevant loop that is showing the data from the database, which should hopefully look something like: while($row = mysql_fetch_assoc($result)){ //code here } And add in the tag: while($row = mysql_fetch_assoc($result)){ //code here echo '<hr />'; } Or do you not have this and are asking how you would go about showing the information in the first place? I wasn't entirely sure from your description of the problem/question.
-
See your other topic. This is exactly why you should have added that topic as a reply to this post.
-
[SOLVED] Perform function on each element of array
GingerRobot replied to sphinx9999's topic in PHP Coding Help
You can also use array_walk if you pass by reference (see the function test_alter in example one here) and you can use a foreach loop like this: <?php $arr=array('3',4,'6','34.4','tr'); foreach($arr as $k => $v){ $arr[$k] = intval($v); } ?> -
Sounds like you need something like: <?php $sql = "SELECT breed.BreedID FROM breed,animal WHERE breed.AnimalTypeID = animalTypeId ORDER BY animal.AnimalID DESC LIMIT 1"; $result = mysql_query($sql) or die(mysql_error()); $breedID = mysql_result($result,0); echo 'BreedID: '.$breedID;a ?> Next time, try adding to your previous topic rather than creating a new one. Dont create two topics on the same subject.
-
I'd use explode: <?php $str = '62:2766f0dd07c471436859ff510c38a618'; list($before,$after) = explode(':',$str); echo $before; ?>
-
If a field exists in both tables, you need to specify the table prefix in the query: SELECT breed.BreedID FROM breed, animal WHERE breed.AnimalTypeID = animal.AnimalTypeID
-
How to change font of Generated Images
GingerRobot replied to turtleman8605's topic in PHP Coding Help
Yes. -
[SOLVED] "explode" giving me "undefined offset" messages
GingerRobot replied to patrickm's topic in PHP Coding Help
Sounds to me like $dump_gegevens->subgroep doesn't always contain the same number of colons, resulting in the generated array containing different numbers of elements. To fix that, and reduce the above bloated code, see: www.php.net/array_search -
[SOLVED] Running a Process in the "Background"
GingerRobot replied to scooter41's topic in PHP Coding Help
Yeah, you can use the flush() function: www.php.net/flush -
users.id refers to the id field in the users table. I suggest you read up on database normalization and joins - selecting data from multiple tables.
-
Fenway, would you even use such a list if you thought you would not need to modify individual values? As you said, its still a pain to search. Just curious - i wasn't sure there was ever a situation where it would be a good idea.
-
Well, STFW comes to mind, though i suppose it's not particularly civil! I think just posting a link to google usually gets the message across.
-
You've closed your if statement. You've one too many closing parenthesis. Try: } if (empty($_FILES['ufile']['tmp_name'][0]) || (strtolower($ext) != "jpg") {
-
Try: UPDATE lner SET notes = REPLACE(notes, 'ex Rod', 'ROD') WHERE notes LIKE '%ex Rod%'
-
[SOLVED] How to count Emplyee Hours from 2 Rows.. ?
GingerRobot replied to techiefreak05's topic in MySQL Help
Im a little confused. What happens after data has been entered twice? So the first time data is entered, it's listed as activityID as being IN? And the second time, its OUT? Then what? And i'll add the third opinion - a timestamp would be much easier. To edit, you can always make the php script to format the timestamp into a more human readable form.